FAQ POWERSHELL IN MALAGASY

By | May 24, 2015

Concept : Ny tena matetika nanontany fanontaniana momba ny Powershell.

Azonao ampiasaina ity lisitra amin’ny fomba samy hafa :

  • To Mandika / Mametaka didy ho any amin’ny soratra
  • Mba jereo haingana ny Syntaxe ny didy manokana
  • Mba hanatsarana ny ara-teknika ny fahalalana
  • Mba mahita didy vaovao
  • Mba hanomanana ny asa resadresaka

Nohavaozina
02 Jolay, 2015
Author powershell-guru.com
Source malagasy.powershell-guru.com
Categories
75
Fanontaniana
610


ACL
Active Directory
Alias
Arrays
Browsers
Certificates
Characters
CIM
Comments
COM Objects
Compare
Computer
Credentials
CSV
Culture
Date
Drives
Environment
Errors
Event Viewer
Files
Folders
Format Operator (-f)
Functions
GPO
GUI
Hardware
Hashtables
Help
History
Jobs
Keyboard
Loops
Math
Memory
Messages
Modules
Microsoft Excel
Microsoft Exchange
Microsoft Outlook
Microsoft SharePoint
Networking
Openfiles
Operators
Parameters
Password
Powershell ISE
Printers
Processes
PSObject
Quest
Random
RDP
Regedit
Regex
Remote
Restore
Scheduled Tasks
Search
SCCM
Services
SMTP
Snapins
Sounds
Static .NET Methods
Strings
System
Try/Catch
Variables
Symantec Vault
Windows10
Windows 2012
Windows Azure
Windows Forms
WMI
XML

System

Ahoana no hamantarana ny dika PowerShell?

Ahoana no mba mihazakazaka PowerShell amin’ny hafa dikan ho an’ny mifanaraka aoriana?
powershell.exe -Version 2.0

Ahoana no mba hitaky ny zara PowerShell Bible (3.0 sy ambony) ao amin’ny soratra amin’ny PowerShell?
#Requires -Version 3.0

Ahoana no mitaky pitantanana tombontsoa ho soratra amin’ny PowerShell?

Ahoana no mba hanamarinana ny masontsivana ny soratra amin’ny PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Ahoana no hahazoana vaovao ho an’ny mpampiasa ankehitriny amin’ny PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Ahoana no mamorona, Ovay, ary Reload ny mombamomba amin’ny PowerShell?

Ahoana no hanao ny fiatoana ny 5 segondra / minitra ao amin’ny soratra amin’ny PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Ahoana no mba fotoana baoty farany amin’ny PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Ahoana no mba hahazoana karazana accelerators amin’ny PowerShell?

Ahoana ny lisitra ny Startup fandaharana amin’ny PowerShell?

Ahoana no uninstall ny fampiharana amin’ny PowerShell?

Ahoana no mba haka Pikantsary avy amin’ny manontolo na ny iray Desktop varavarankely mavitrika amin’ny PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Ahoana ny hahazoana ny hafatra hanisanareo MSMQ filaharam-be amin’ny PowerShell?

Ahoana no nametraka ny famonoana amin’ny PowerShell politika?

Ahoana no mba hamoronana hitsin amin’ny PowerShell?

Ahoana no mametaka na unpin ny fandaharana ho amin’ny taskbar amin’ny PowerShell?

Ahoana no hanokatra ny Windows Explorer amin’ny PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Ahoana ny lisitra fitaovana mpamily amin’ny PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Ahoana no mba hamoronana GUID amin’ny PowerShell?

Ahoana no mba haka ny toerana misy ny tsy maharitra lahatahiry ho an’ny mpampiasa ny ankehitriny amin’ny PowerShell?
[System.IO.Path]::GetTempPath()

Ahoana no mba hanatevin-daharana ny lalana sy ny ankizy lalana ho lalana iray monja amin’ny PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Ahoana ny lisitra cmdlets rehetra “Get- *” amin’ny PowerShell?
Get-Command -Verb Get

Ahoana ny lisitra rafitra manokana folders amin’ny PowerShell?

Ahoana no an-tendrombohitra ISO / VHD antontan-taratasy amin’ny PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Ahoana no mba hanamarina .NET Framework dikan-nametraka ny PowerShell?

Ahoana no mba hijery raha toa ka .NET Framework 4.5 Version dia Napetraka amin’ny PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Ny fomba hanombohana sy hampitsahatra ny transcript (mba hamoronana ny rakitsoratry ny Windows PowerShell fotoam-pivoriana) amin’ny PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Ahoana no mba hanova ny ankehitriny Directory ho amin’ny toerana manokana amin’ny PowerShell?
Set-Location -Path 'C:\scripts'

Ahoana no hanadio ny lamba amin’ny PowerShell?
Clear-Host
cls # Alias

Ahoana no mba hanova ny fampisehoana fanapahan-kevitra amin’ny PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Ahoana no nametraka ny “lamba feno” varavarankely amin’ny PowerShell?
mode.com 300

Ahoana no mba Dimensions (sakany sy ny haavony) ny sary amin’ny PowerShell?

Ahoana no hahazoana ny Windows vokatra fototra amin’ny PowerShell?

Perfmon

Ahoana no hahazoana ny ankehitriny “% processeur Time” (salan) any am-parany 5 segondra (in-10) amin’ny PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Ahoana no mba hampidiran’izy fivoriambe amin’ny PowerShell?

Ahoana no mba hijery .NET amin’izao fotoana feno PowerShell fivoriambe?

Ahoana no Amantarana ny GAC (Global Assembly Cache) lalana amin’ny PowerShell?

Clipboard

Ahoana no mandika ny valiny amin’ny clipboard amin’ny PowerShell?

Ahoana no hahazoana ny votoatin’ny ny clipboard amin’ny PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Ahoana no hahazoana ny hotfixes fahefana amin’ny PowerShell?
Get-HotFix -ComputerName $computer

Ahoana no hahazoana ny hotfixes fahefana eo anoloan’ny / aorian’ny daty iray manokana amin’ny PowerShell?
Get-HotFix | Where-Object -FilterScript { $_.InstalledOn -lt ([DateTime]'01/01/2015') } # Before 01/01/2015
Get-HotFix | Where-Object -FilterScript {$_.InstalledOn -gt ([DateTime]'01/01/2015')} # After 01/01/2015

Ahoana no mba hijerena raha misy hotfix no Napetraka amin’ny PowerShell?
Get-HotFix -Id KB2965142

Ahoana no hahazoana ny hotfixes nametraka amin’ny solosaina lavitra amin’ny PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Ahoana no mba hahazoana vaovao amin’ny PowerShell Pagefile?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Ahoana no hahazoana ny soso-kevitra habeny (MB) ho an’ny Pagefile amin’ny PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Ahoana no mba hamoronana Pagefile (4096 MB) eo amin’ny (D 🙂 mitondra fiara amin’ny PowerShell?

Ahoana no mba hamafa ny Pagefile ny (C 🙂 mitondra fiara amin’ny PowerShell?

Maintenance

Ahoana no mba hanamarinana ny fitsinjarazarana ny fiara amin’ny PowerShell?

Ahoana no mba hijerena ny kapila toerana ny aelin’ny amin’ny PowerShell?

Up


Files

Ahoana no hanokatra misy rakitra iray mitondra PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Ahoana no mba hamaky misy rakitra iray mitondra PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Ahoana no mba hanoratra Output ho misy rakitra iray mitondra PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Ahoana no hahazoana ny fullname ny ankehitriny rakitra teny amin’ny PowerShell?
$MyInvocation.MyCommand.Path

Ahoana no hanery / zip antontan-taratasy amin’ny PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Ahoana no uncompress / unzip rakitra amin’ny PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Ahoana ny mahita ny rakitra ao amin’ny ZIP tahiry amin’ny PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Ahoana no maneho ny haben’ny ny rakitra ao amin’ny KB amin’ny PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Ahoana no mahita rakitra lehibe na latsaky ny 1 GB amin’ny PowerShell?

Ahoana no mba haneho ny anaran ‘ny antontan-taratasy tsy misy ny fanitarana amin’ny PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Ahoana no mba haneho ny fanitarana ny misy rakitra iray mitondra PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Ahoana no hahazoana ny rakitra Version ny misy rakitra iray mitondra PowerShell?

Ahoana no hahazoana ny hash ny misy rakitra iray mitondra PowerShell?
(Get-FileHash $file).Hash

Ahoana no hahazoana ny MD5 / SHA1 checksum ny misy rakitra iray mitondra PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Ahoana no mba haneho rakitra miafina amin’ny PowerShell?

Ahoana no mba hijerena raha misy rakitra manana fanitarana amin’ny PowerShell?

Ahoana no mba hametraka ny rakitra toy ny “Vakio ihany” amin’ny PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Ahoana ny hanova ny “LastWriteTime” toetra ny tamin’ny herinandro lasa ho misy rakitra iray mitondra PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Ahoana no mba hamoronana rakitra vaovao amin’ny PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Ahoana no rename misy rakitra iray mitondra PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Ahoana ny ankamaroan’ny / batch rename antontan-taratasy maro amin’ny PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Ahoana no hamafa misy rakitra iray mitondra PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Ahoana no mba haneho ny 10 andalana farany ny misy rakitra iray mitondra PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Ahoana no unblock rakitra maro ny fampirimana amin’ny PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Ny hanesorana foana tsipika avy misy rakitra iray mitondra PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Ahoana no mba hijerena raha misy rakitra misy amin’ny PowerShell?

Ahoana no hahazoana ny vaovao / namorona ny tahiry tranainy indrindra ao amin’ny fampirimana amin’ny PowerShell?

Ny hanesorana dika mitovy avy tsipika misy rakitra iray mitondra PowerShell?

Ahoana no mba hahazoana rakitra noforonina mihoatra na latsaky ny 1 volana ao amin’ny fampirimana amin’ny PowerShell?

Ahoana no mba hahazoana rakitra noforonina mihoatra na latsaky ny 1 taona ao amin’ny fampirimana amin’ny PowerShell?

Ahoana ny fanondranana ny lanjan’ny ny miova ho misy rakitra iray mitondra PowerShell?
Set-Content -Path file.txt -Value $variable

Hanisa ny isan’ny antontan-taratasy (* .txt) ao amin’ny fampirimana amin’ny PowerShell?

Ahoana no mba hitady ny kofehy maromaro ao anatin’ny antontan-taratasy amin’ny PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Test'

Ahoana no mba haneho ny voalohany / andalana farany misy rakitra iray mitondra PowerShell?

Ahoana no maneho ny isan’ny andalana manokana misy rakitra iray mitondra PowerShell?

Hanisa ny isan’ny andalana ny misy rakitra iray mitondra PowerShell?

Hanisa ny isan’ny litera sy ny teny misy rakitra iray mitondra PowerShell?

Ahoana no misintona misy rakitra iray mitondra PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Ahoana no mba haneho ny lalan’ny feno ny misy rakitra iray mitondra PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Ahoana no adika antontan-taratasy iray ny fampirimana amin’ny PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Ahoana no adika iray amin’ny antontan-taratasy maro folders amin’ny PowerShell?

Ahoana no adika maro Folder rakitra ho iray amin’ny PowerShell?
Get-ChildItem -Path 'C:\source' -Filter *.txt | Copy-Item -Destination 'C:\destination'

Up


Active Directory

Domain & Forest

Computers

Groups

Organizational Unit (OU)

Users

Domain & Forest

Ny Fomba Hahitana ny Global Catalog lohamilina amin’ny Active Directory amin’ny PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Ahoana no hahitana toerana amin’ny Active Directory amin’ny PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Ahoana no Amantarana ny ankehitriny amin’ny PowerShell sehatra maso?
(Get-ADDomainController).HostName

Ahoana no hahitana ny sehatra rehetra eo amin’ny sehatra mpanara-maso amin’ny PowerShell?

Ahoana no Amantarana ny taorian’i JK replication tsy fahombiazana amin’ny PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Ahoana no Amantarana ny tombstone androm-piainany ho ny ala amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba antsipirian’ny ny ala / sehatry amin’ny Active Directory amin’ny PowerShell?

Ahoana no hahazoana ny lalan’ny ny “Fafao zavatra” fitoeran-javatra ao amin’ny Active Directory amin’ny PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Ahoana no hahatonga ny taorian’i JK efa niasa Bin tarehin-javatra eo amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba hamerina ny taorian’i JK Account avy amin’ny efa niasa Bin amin’ny Active Directory amin’ny PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Ahoana no Amantarana ny FSMO andraikitra amin’ny PowerShell?

Ahoana no mifandray amin’ny sehatra manokana amin’ny PowerShell-maso?
Get-ADUser -Identity $user -Server 'serverDC01'

Ahoana no hahazoana ny ankehitriny mpizara logon amin’ny PowerShell?

Ahoana no hanao “gpupdate” ao amin’ny solosaina amin’ny PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Ahoana no mba hamorona vondrona vaovao amin’ny Active Directory amin’ny PowerShell?

Ny hanesorana ny vondrona amin’ny Active Directory amin’ny PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Ahoana no manampy ny mpampiasa ny vondrona amin’ny Active Directory amin’ny PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Ny hanesorana ny mpampiasa avy amin’ny vondrona ao amin’ny Active Directory amin’ny PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Ny Fomba Hahitana ny vondrona foana (tsy misy mpikambana) amin’ny Active Directory amin’ny PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Hanisa vondrona foana (tsy misy mpikambana) amin’ny Active Directory amin’ny PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Ahoana no hahazoana ny mpikambana ao amin’ny vondrona eo amin’ny Active Directory amin’ny PowerShell?

Ahoana no hahazoana ny mpikambana ao amin’ny vondrona iray miaraka amin’ny recursive mpikambana ao amin’ny Active Directory amin’ny PowerShell?

Hanisa ny isan’ny mpikambana ao amin’ny vondrona tamin’ny / tsy recursive mpikambana ao amin’ny Active Directory amin’ny PowerShell?

Users

Ahoana ny fampiasana ny wildcard ao amin’ny sivana ny “Get-ADUser” amin’ny Active Directory amin’ny PowerShell?

Ahoana raha te hamindra mpampiasa OU hafa amin’ny Active Directory amin’ny PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Ahoana no mahita ireo rehetra momba izay (Nested) ho an’ny mpampiasa amin’ny PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Ahoana no hahazoana ny mpikambana (fohy anarana / truncated) ho an’ny mpampiasa iray amin’ny PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Ahoana no rename ny Name (FullName), (DisplayName), GivenName (FirstName), ary Surname (LastName) ho mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba hanova ny Description, Biraon’ny, ary Telephone isan’ny mpampiasa ho tantara ao amin’ny Active Directory amin’ny PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Ahoana no nametraka ny lany daty ny “31/12/2015” na “Tsy” ho mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba hamaha ny mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?
Unlock-ADAccount $samAccountName

Ahoana no hahafahan’ny / rohin-drakitra tapaka ny mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?

Ny hanesorana ny mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?
Remove-ADUser $samAccountName

Ahoana no Reset ny tenimiafina ho an’ny mpampiasa iray tantara amin’ny Active Directory amin’ny PowerShell?

Ahoana no Reset ny tenimiafina ho an’ny mpampiasa maro tantara (ambongadiny) amin’ny Active Directory amin’ny PowerShell?

Ahoana no Amantarana ny tompon-antontan-taratasy ao amin’ny Active Directory amin’ny PowerShell?

Ahoana no Amantarana ny OU (fandaminana Unit) ho an’ny mpampiasa iray ao amin’ny Active Directory amin’ny PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Ny Fomba Hahitana ny mpampiasa kilema kaonty amin’ny Active Directory amin’ny PowerShell?

Ny Fomba Hahitana ny mpampiasa lany daty kaonty amin’ny Active Directory amin’ny PowerShell?
Search-ADAccount -AccountExpired

Ny Fomba Hahitana ny mpampiasa mihidy kaonty amin’ny Active Directory amin’ny PowerShell?
Search-ADAccount -LockedOut

Ahoana no Amantarana ny Sid ny mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Ahoana no mba hiova finoana ny anaram-pikambana an’i Sid amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba hiova finoana ny Sid ny solonanarana amin’ny Active Directory amin’ny PowerShell?

Ahoana no namaky ny kaja Anaran’ny mpampiasa kaonty amin’ny Active Directory amin’ny PowerShell?

Ahoana no Amantarana ny daty ny famoronana / fanovana ny tantara mpisera amin’ny Active Directory amin’ny PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Ahoana no mba haneho ny tsy voatery ary maintsy fananana ho an’ny kilasy “User” amin’ny Active Directory amin’ny PowerShell?

Ahoana no hahazoana ny LDAP lalan’ny dia iray mpampiasa amin’ny Active Directory amin’ny PowerShell?

Ahoana no mba hanova ny CN (kanônika Name) ho an’ny mpampiasa iray ao amin’ny Active Directory amin’ny PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Test Powershell'

Ahoana no hahazoana ny fandaminana Unit (OU) ray aman-dreny ny mpampiasa amin’ny Active Directory amin’ny PowerShell?

Ahoana no hahazoana ny tompon’ny iray mpampiasa (izay namorona ny tantara) amin’ny Active Directory amin’ny PowerShell?

Ny fomba famadihan- ny PwdLastSet toetra ho mpampiasa amin’ny Active Directory amin’ny PowerShell?

Computers

Ahoana no mba hizaha toetra ny azo antoka fantsona eo amin’ny solosaina an-toerana sy ny sehatra amin’ny PowerShell?
Test-ComputerSecureChannel

Ahoana no izy mba hamboatra ny azo antoka fantsona eo amin’ny solosaina an-toerana sy ny sehatra amin’ny PowerShell?
Test-ComputerSecureChannel -Repair

Ahoana no rohin-drakitra tapaka solosaina tantara ao amin’ny Active Directory amin’ny PowerShell?
Disable-ADAccount $computer

Ahoana no mba nahita solosaina amin’ny Operating manokana Systems in Active Directory amin’ny PowerShell?

Organizational Unit (OU)

Ahoana no mamorona ny fandaminana Unit (OU) amin’ny Active Directory amin’ny PowerShell?
New-ADOrganizationalUnit -Name 'TEST' -Path 'DC=domain,DC=com'

Ahoana no mba fandaminana Unit (OU) antsipirihany in Active Directory amin’ny PowerShell?
Get-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Properties *

Ahoana no mba hanova ny famaritana ny iray fandaminana Unit (OU) amin’ny Active Directory amin’ny PowerShell?
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Description 'My description'

Ahoana no hahafahan’ny / rohin-drakitra tapaka ny fandaminana Unit (OU) avy amin’ny nahy famafana amin’ny Active Directory amin’ny PowerShell?

Ahoana no hahatonga ny nahy famafana ho an’ny rehetra ny fandaminana Unit (OU) amin’ny Active Directory amin’ny PowerShell?

Ahoana no hamafa ny fandaminana Unit (OU) voaaro amin’ny nahy famafana amin’ny Active Directory amin’ny PowerShell?

Ny fomba famadihan- iray niavaka Anaran’ny ny fandaminana Unit (OU) ho kanônika Name amin’ny Active Directory amin’ny PowerShell?

Ahoana ny fandaminana foana tsy mitondra fanatitra lisitra Units (OUs) amin’ny PowerShell?

Ahoana no hahazoana ny mpitantana ny vondrona amin’ny PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Ny hanesorana ny adiresy IP v4 (80.80.228.8) miaraka amin’ny Verses amin’ny PowerShell?
$example = 'The IP address is 80.80.228.8'
$ip = [regex]::match($example,'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').value

Ny hanesorana ny adiresy MAC (C0-D9-62-39-61-2D) amin’ny Separator “-” amin’ny Verses amin’ny PowerShell?
$example = 'The MAC address is C0-D9-62-39-61-2D'
$mac = [regex]::match($example,'([0-9A-F]{2}[-]){5}([0-9A-F]{2})').value

Ny hanesorana ny adiresy MAC (C0: E9: 62: 39: 61: 2D) miaraka amin’ny Separator “:” amin’ny Verses amin’ny PowerShell?
$example = 'The MAC address is C0:D9:62:39:61:2D'
$mac = [regex]::match($example,'((\d|([a-f]|[A-F])){2}:){5}(\d|([a-f]|[A-F])){2}').value

Ny hanesorana ny daty (10/02/2015) miaraka amin’ny Verses amin’ny PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Ny hanesorana ny URL (www.powershell-guru.com) miaraka amin’ny Verses amin’ny PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Ny hanesorana mailaka (user@domain.com) miaraka amin’ny Verses amin’ny PowerShell?
$example = 'The email is user@domain.com'
$email = [regex]::match($example,'(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b').value

Ny hanesorana “guru” avy amin’ny kofehy ohatra amin’ny Verses amin’ny PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Ny hanesorana “guru.com” avy amin’ny kofehy ohatra amin’ny Verses amin’ny PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Ny hanesorana “powershell-guru.com” avy amin’ny kofehy ohatra amin’ny Verses amin’ny PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Ny hanesorana “123” avy amin’ny kofehy ohatra amin’ny Verses amin’ny PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Ny hanesorana “$” (dolara famantarana) avy amin’ny kofehy ohatra amin’ny Verses amin’ny PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Ny fomba hanoloana ny toetra amam-panahy (* .com) amin’ny iray hafa (* .fr) ao amin’ny tady amin’ny Verses amin’ny PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Ahoana no mba handositra ny kofehy amin’ny Verses amin’ny PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Ahoana no mba hanery ny famoriam-bola ny fahatsiarovana ny fako hetra amin’ny PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Ahoana no hahazoana ny RAM haben’ny ordinatera amin’ny PowerShell?

Up


Date

Ahoana no hahazoana ny daty ankehitriny amin’ny PowerShell?
Get-Date
[Datetime]::Now

Ahoana no mba haneho ny daty amin’ny endriny isan-karazany amin’ny PowerShell?

Ny fomba famadihan- daty (Datetime) ny daty (String) amin’ny PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

Ny fomba famadihan- daty (String) ny daty (Datetime) amin’ny PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Ahoana no kajy ny fahasamihafana (isan’ny andro, ora, Minitra, na seconds) eo amin’ny roa daty amin’ny PowerShell?
(New-TimeSpan -Start $dateStart -End $dateEnd).Days
(New-TimeSpan -Start $dateStart -End $dateEnd).Hours
(New-TimeSpan -Start $dateStart -End $dateEnd).Minutes
(New-TimeSpan -Start $dateStart -End $dateEnd).Seconds

Ahoana no mba hampitaha ny daty roa amin’ny PowerShell?
(Get-Date 2015-01-01) -lt (Get-Date 2015-01-30) # True
(Get-Date 2015-01-01) -gt (Get-Date 2015-01-30) # False

Ahoana no mba hiezaka handamina ny voaomana ny daty toy ny “Datetime” amin’ny PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Ny fomba hanombohana sy hampitsahatra ny stopwatch amin’ny PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Ahoana no hahazoana ny amin’izao fotoana izao andro amin’ny herinandro amin’ny PowerShell?
(Get-Date).DayOfWeek #Sunday

Ahoana no mba omaly ny daty amin’ny PowerShell?
(Get-Date).AddDays(-1)

Ahoana no hahazoana ny isan’ny andro ao amin’ny iray volana (volana Febroary 2015) amin’ny PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Ahoana no mba mahafantatra ny dingana taona PowerShell?
[DateTime]::IsLeapYear(2015)

Ahoana ny lisitra fotoana faritra amin’ny PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Ahoana ny isa (ny ascii endrika) ary decode ny URL amin’ny PowerShell?

Inona avy ireo tambajotra equivalents ny teratany didy amin’ny PowerShell?

Ahoana no hahazoana adiresy IP amin’ny PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Ahoana no rohin-drakitra tapaka adiresy IP v6 (IPv6) amin’ny PowerShell?

Ahoana no kery ny adiresy IP v4 (IPv4) amin’ny PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Ahoana no Amantarana ny adiresy IP ivelany amin’ny PowerShell?

Ahoana no Amantarana ny Hostname avy amin’ny adiresy IP amin’ny PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Ahoana no Amantarana ny adiresy IP avy amin’ny Hostname amin’ny PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Ahoana no Amantarana ny FQDN avy amin’ny Hostname amin’ny PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Ahoana no Amantarana ny tambajotra fanahafana (Ip, Subnet, Fidirana, ary ny DNS) amin’ny PowerShell?

Ahoana no Amantarana ny adiresy MAC amin’ny PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Ahoana no Ping ny solosaina amin’ny PowerShell?

Ahoana no mba hijerena raha misy solosaina dia mifandray amin’ny aterineto amin’ny PowerShell?

Ahoana no mba hanao ny “whois” lookup ho an’ny vohikala iray amin’ny PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Ahoana no mba tsipiriany ny IP-bahoaka (fanondroana ara-jeografika) amin’ny PowerShell?

Ahoana no mba hijerena raha misy seranan-tsambo misokatra / nikatona tamin’ny PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Ahoana no hanao “tracert” amin’ny PowerShell?
Test-NetConnection www.google.com -TraceRoute

Ahoana no manamboatra ny trano fifandraisana tambajotram mombamomba amin’ny PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Ahoana no hampisehoana ny TCP fifandraisana amin’ny PowerShell seranan-tsambo?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Ahoana no manafohy lava URL ho kely URL amin’ny PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Ahoana no mba hisolo tena toe-javatra amin’ny PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Ahoana no mba hijerena ny DNS cache amin’ny solosaina an-toerana amin’ny PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Ahoana no mba hanadio ny DNS cache amin’ny solosaina an-toerana amin’ny PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Ahoana no mba hanadio ny DNS cache amin’ny solosaina lavitra amin’ny PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Ahoana ny famakiana ny Tompon’ny maro hametraka amin’ny PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Ahoana no hiteraka ny kisendrasendra tamin’i PowerShell tenimiafina?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Ahoana no mba hanova ny teny miafina eo an-toerana ho mpitantana amin’ny mpizara lavitra amin’ny PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Ahoana no Amantarana ny tenimiafina lany daty ny kaonty amin’ny Active Directory amin’ny PowerShell?

Up


Printers

Ahoana ny lisitra ny mpanonta rehetra ho iray manokana amin’ny PowerShell lohamilina?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Ahoana ny lisitra ny seranan-tsambo rehetra ho an’ny lohamilina manokana amin’ny PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Ahoana no mba hanova ny fanehoan-kevitra / toerana ny mpanonta printy tamin’i PowerShell?

Ahoana no mba hanadio (hanafoana ny asa) ny mpanonta amin’ny PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Ahoana no hanao pirinty ny pejy fitsapana ho mpanonta printy tamin’i PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Ahoana no mba printy filaharam-be ho an’ny mpanonta amin’ny PowerShell?

Up


Regedit

Read

Ahoana ny lisitra firaketana toho-tanteliny amin’ny PowerShell?
Get-ChildItem -Path Registry::

Ahoana no mba firaketana soatoavina sy ny lanjany amin’ny PowerShell karazana?

Ahoana ny lisitra firaketana subkeys manan-danja amin’ny PowerShell?

Ahoana ny lisitra firaketana subkeys manan-danja amin’ny fomba recursive amin’ny PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Ahoana no hahitana subkeys amin’ny anarana manokana amin’ny PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Ahoana no hiverina ihany ny anaran ‘ny lisitra subkeys amin’ny PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Ahoana ny lisitra firaketana soatoavina amin’ny PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Ahoana no mba hamaky lisitra iray manokana zava-dehibe amin’ny PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Ahoana no mba hamaky lisitra iray manokana zava-dehibe amin’ny solosaina lavitra amin’ny PowerShell?

Write

Ahoana no mamorona lisitra vaovao fanalahidy amin’ny PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Ahoana no mba hamoronana zava-dehibe amin’ny PowerShell lisitra?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Ahoana no manova ny misy zava-dehibe amin’ny PowerShell firaketana?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Ahoana no mba hamafa ny lisitra zava-dehibe amin’ny PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Ahoana no mba hamafa ny lisitra fanalahidy amin’ny PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Ahoana no hitsapana raha misy lisitra key misy amin’ny PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Ahoana no hitsapana raha misy lisitra misy zava-dehibe amin’ny PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Ny hanesorana fotsy-toerana mpandray anjara hatrany am-piandohana ny kofehy amin’ny PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Ny hanesorana fotsy-toerana mpandray anjara avy any amin’ny faran’ny ny kofehy amin’ny PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Ny hanesorana fotsy-toerana mpandray anjara (manomboka sy mamarana) ny kofehy amin’ny PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Ahoana no mba hiova finoana ny kofehy ho ambony nanjo an’i PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Ahoana no mba hiova finoana ny tady mba hampidina nanjo an’i PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Ahoana no mifidy ny substring “PowerShell” ao amin’ny kofehy “PowerShellGuru” amin’ny PowerShell?
$string.Substring(0,10)

Ahoana no mifidy ny substring “Guru” ao amin’ny kofehy “PowerShellGuru” amin’ny PowerShell?
$string.Substring(10)

Ahoana no mifidy ny isa “123” ny “PowerShell123Guru” amin’ny PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Ahoana no hahazoana ny aotra-monina Index ny “Guru” ny amin’ny kofehy “PowerShellGuru” amin’ny PowerShell?
$string.IndexOf('Guru') # 10

Ahoana no mba hijerena raha misy tady no tohivakana foana na amin’ny PowerShell foana?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Ahoana no mba hijerena raha misy tady no tohivakana foana, foana, na ahitana afa-tsy ny fotsy-toerana anjara amin’ny PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Ahoana no mba hijerena raha misy tady Misy taratasy manokana amin’ny PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Ahoana no mba hiverina ny halavan’ny iray amin’ny PowerShell kofehy?
$string.Length

Ahoana no concatenate tady roa amin’ny PowerShell?

Ahoana no mifanaraka ny iray na maromaro fononteny mahitsy “[]” eo amin’ny tady amin’ny PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Ahoana no mifanaraka ny iray na maro fononteny “()” tao amin’ny tady amin’ny PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Ahoana no mifanaraka ny iray na maromaro olioly fononteny mahitsy “{}” ao amin’ny tady amin’ny PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Ahoana no mifanaraka ny iray na maromaro fononteny mahitsy zoro “<>” ao amin’ny tady amin’ny PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Ahoana no mifanaraka na lowercase taratasy (ABC) amin’ny tady amin’ny PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Ahoana no mifanaraka na upperletters (ABC) amin’ny tady amin’ny PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Ahoana no mifanaraka “[P” (p ambany tranga) amin’ny tady amin’ny PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Ahoana no mifanaraka “[P” (P ambony tranga) amin’ny tady amin’ny PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Ny fomba hanoloana ny andalana hafa mifanaraka amin’ny PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Ny fomba famadihan- asa nisara-kevitra ny tady (isan-jato) amin’ny PowerShell?
(1/2).ToString('P')

Ahoana ny manatsara ny kofehy misy isa amin’ny PowerShell?

Ahoana no mifidy ny teny farany ny fehezanteny amin’ny PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ')[-1] # Returns Powershell

Ahoana no hahazoana ny lehibe indrindra tenin’ny fehezanteny iray amin’ny PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Powershell

Hanisa ny isan’ny fotoana ny tady dia fanomezana ao anatin’ny fehezanteny amin’ny PowerShell?
$sentence = 'test test test Powershell'
[regex]::Matches($sentence, 'test').Count # Returns 3

Ahoana no mba handika mpandray anjara tsirairay ao amin’ny tady ny toetra voaomana amin’ny PowerShell?

Ahoana no mba hampiova finoana ny taratasiny voalohany ho uppercase ny kofehy amin’ny PowerShell?

Ahoana ny pad (ankavia na ankavanana) ny kofehy amin’ny PowerShell?

Ahoana ny isa sy decode ny kofehy ho Base64 amin’ny PowerShell?

Ny fomba famadihan- maro (ny, ary avy) binary amin’ny PowerShell?

Ahoana no hiverina ihany ny ray aman-dreny farany fampirimana amin’ny lalana amin’ny PowerShell?

Ahoana no hiverina ihany ny zavatra farany amin’ny lalana amin’ny PowerShell?

Up


Math

Ahoana ny lisitra ny fomba ny System.Math kilasy amin’ny PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Ahoana no mba hiverina ny tena zava-dehibe amin’ny PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Ahoana no mba hiverina ny zoro izay no fepetra tsy isan’ny manokana amin’ny PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Ahoana no mba hiverina ny valin-drihana zava-dehibe amin’ny PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Ahoana no mba hiverina ny tany zava-dehibe amin’ny PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Ahoana no miverina ny ara-nofo (base e) logarithm ny maro amin’ny PowerShell manokana?
[Math]::Log(4) #Returns 1,38629436111989

Ahoana no mba hiverina ny fototra 10 logarithm ny maro amin’ny PowerShell manokana?
[Math]::Log10(4) #Returns 0,602059991327962

Ahoana no mba hiverina ny indrindra ny soatoavina amin’ny PowerShell roa?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Ahoana no mba hiverina ny kely indrindra ny soatoavina amin’ny PowerShell roa?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Ahoana no mba hiverina maro atsangana ho amin’ny fahefana manokana amin’ny PowerShell?
[Math]::Pow(2,4) #Returns 16

Ahoana no mba hiverina ny decimal danja ny zava-dehibe akaiky indrindra amin’ny PowerShell manontolo?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Ahoana no mba hiverina ny anisan’ny iray manokana amin’ny PowerShell decimal maro?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Ahoana no mba hiverina ny tora-droa fototry ny iray manokana amin’ny PowerShell maro?
[Math]::Sqrt(16) #Returns 4

Ahoana no mba hiverina ny Pi tapaka amin’ny PowerShell?
[Math]::Pi #Returns 3,14159265358979

Ahoana no miverina ny ara-nofo logarithmic fototra (foana e) amin’ny PowerShell?
[Math]::E #Returns 2,71828182845905

Ahoana no mba hijery raha toa ka maro no na hafahafa na dia amin’ny PowerShell?
[bool]($number%2)

Up


Hashtables

Ahoana no mamorona foana hashtable amin’ny PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Ahoana no mba hamoronana hashtable amin’ny entana amin’ny PowerShell?

Ahoana no mba hamoronana hashtable Nalahatra araka ny key / anarana (baiko rakibolana) miaraka amin’ny entana amin’ny PowerShell?

Ahoana no manampy zavatra (manan-danja-value mpivady) ny hashtable amin’ny PowerShell?
$hashtable.Add('Key3', 'Value3')

Ahoana no mba zava-dehibe manokana ny hashtable amin’ny PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Ahoana no hahazoana ny faran’izay kely vidy ny hashtable amin’ny PowerShell?

Ahoana no hahazoana ny faran’izay zava-dehibe ny hashtable amin’ny PowerShell?

Ahoana no manova zavatra eo amin’ny hashtable amin’ny PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Ny hanesorana zavatra ao amin’ny hashtable amin’ny PowerShell?
$hashtable.Remove('Key1')

Ahoana no mba hanadio ny hashtable amin’ny PowerShell?
$hashtable.Clear()

Ahoana no mba hanamarinana ny fisian’ny iray manan-danja manokana / zava-dehibe eo amin’ny hashtable amin’ny PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Ahoana no Milahatra araka ny fototra / zava-dehibe eo amin’ny hashtable amin’ny PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Ahoana no mamorona foana voaomana amin’ny PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Ahoana no mba hamorona ny voaomana amin’ny entana amin’ny PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Ahoana no manampy zavatra ho amin’ny voaomana amin’ny PowerShell?
$array += 'D'
[void]$array.Add('D')

Ahoana no manova ny zavatra eo amin’ny voaomana amin’ny PowerShell?
$array[0] = 'Z' # 1st item[0]

Ahoana no mba hanamarinana ny haben’ny ny voaomana amin’ny PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Ahoana no retrieve zavatra iray / maro / zavatra rehetra ao amin’ny voaomana amin’ny PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Ny hanesorana zavatra foana ao amin’ny voaomana amin’ny PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Ahoana no mba hijery raha toa ka misy zavatra misy any amin’ny voaomana amin’ny PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Ahoana no Amantarana ny Fanondroana iray isan’ny zavatra ao amin’ny voaomana amin’ny PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Ahoana no hanova ny filaharan’ny zavatra ao amin’ny voaomana amin’ny PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Ahoana no hiteraka ny kisendrasendra zavatra avy amin’ny voaomana amin’ny PowerShell?
$array | Get-Random

Ahoana no mba hiezaka handamina ny voaomana ao amin’ny miakatra / midina fomba amin’ny PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Hanisa ny isan’ny zavatra ao amin’ny voaomana amin’ny PowerShell?
$array.Count

Inona no hanampy ny voaomana ho namany amin’ny PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Ahoana no mba mahita anarana mitovy avy amin’ny voaomana amin’ny PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Ny hanesorana anarana mitovy avy amin’ny voaomana amin’ny PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Ahoana no mba hamorona ny zavatra voaomana tamin’ny manomboka amin’ny tovona (“user01”, “user02”, … “user10”) amin’ny PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Ahoana ny lisitra ACL ny iray mpampiasa taorian’i JK amin’ny PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Ahoana ny lisitra ACL ny fampirimana amin’ny PowerShell?
(Get-Acl -Path C:\scripts).Access

Ahoana ny lisitra fahazoan-dalana manokana ACL ampy (mpampiasa na ny vondrona) ny mpampiasa taorian’i JK amin’ny PowerShell?

Up


Variables

Inona avy ireo karazana tahirin-kevitra mahazatra indrindra amin’ny PowerShell?

Ahoana no Amantarana ny kely indrindra sy ny toetra tsara indrindra nandritra ny karazany hiovaova amin’ny PowerShell?

Ahoana no mba hizaha toetra ny datatype amin’ny PowerShell?

Ahoana no mba hamoronana-String miova eto amin’ny PowerShell?