FAQ POWERSHELL IN MAORI

By | May 24, 2015

Ariā: Ko te ui tino auau pātai e pā ana ki Powershell.

Ka taea e koe te whakamahi i tēnei rārangi i roto i te huarahi rerekē:

  • Hei tārua / whakahau whakapiri ki te hōtuhi
  • Hei kite i hohoro te wetereo o te whakahau motuhake
  • Ki te whakapai ake i to koutou matauranga hangarau
  • Ki te ite i whakahau hou
  • No te faaineine i te uiuiraa mahi

Whakahoutia
Hōngongoi 02, 2015
Kaituhi powershell-guru.com
Pūtake maori.powershell-guru.com
Ngā Kāwai
75
Pātai
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

Pehea ki te whakatau i toku putanga o PowerShell?

Pehea ki te whakahaere i PowerShell i roto i tetahi putanga mo te hototahi whakamuri?
powershell.exe -Version 2.0

How ki te rapu utu i te putanga PowerShell iti (3.0 me te teitei) i roto i te hōtuhi ki PowerShell?
#Requires -Version 3.0

Pehea ki te rapu utu haamaitairaa whakahaere mō te hōtuhi ki PowerShell?

Pehea ki te tirohia i te tawhā o te hōtuhi ki PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Ki te tiki mōhiohio mō te kaiwhakamahi o nāianei ki PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Ki te hanga, whakatika, ka tāuta anō i te kōtaha ki PowerShell?

Pehea ki te mahi i te okioki i o te 5 hēkona / meneti i roto i te hōtuhi ki PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Ki te tiki i te wa whakaara whakamutunga ki PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Me pēhea te ki te tiki accelerators momo ki PowerShell?

How ki te hiki i te hōtaka whakaoho ki PowerShell?

Ki te tango i tētahi tono ki a PowerShell?

Ki te tango i te Whakaahuamata o te papamahi katoa o te matapihi hohe ki te PowerShell ranei?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Ki te tiki i te tatau karere mo MSMQ rārangi ki PowerShell?

Ki te whakaturia te kaupapa mahia ki PowerShell?

Pehea ki te waihanga i tētahi pokatata ki PowerShell?

Pehea ki te titi Wetea i tētahi hōtaka ki te paetaumahi ki PowerShell ranei?

Pehea ki te whakatuwhera i te Explorer Windows ki PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Pehea ki te hiki atekōkiri pūrere ki PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Ki te hanga i te TTAA ki PowerShell?

Pehea ki te tiki i te wāhi o te whaiaronga rangitahi mō te kaiwhakamahi o nāianei ki PowerShell?
[System.IO.Path]::GetTempPath()

Pēhea te hono i te ara, me te ara te tamaiti ki roto ki tetahi ara kotahi ki a PowerShell?
Join-Path -Path C:\ -ChildPath \windows

How ki te whakarārangi cmdlets katoa “te ro◊i *” ki PowerShell?
Get-Command -Verb Get

How ki te hiki kōpaki pūnaha makehe mo PowerShell?

How ki te Maunga kōnae / VHD ISO ki PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Pehea ki te tirohia putanga .NET Framework tāutatia ki PowerShell?

Pehea ki te tirohia ki te tāuta i te .NET Framework putanga 4.5 i te PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Pehea ki te tīmata me te mutu i te tuhinga (ki te hanga i tētahi pūkete o te wātū Windows PowerShell) ki PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Pehea ki te huri i te whaiaronga o nāianei ki te wāhi motuhake ki a PowerShell?
Set-Location -Path 'C:\scripts'

Pehea ki te ūkui i te mata ki a PowerShell?
Clear-Host
cls # Alias

Ki te huri i te taumira whakaatu ki a PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Ki te whakaturia te matapihi “mata tonu” ki PowerShell?
mode.com 300

Ki te tiki āhuatanga (whānui me te teitei) o te pikitia ki PowerShell?

Ki te tiki i te kī hua Windows ki PowerShell?

Perfmon

Ki te tiki i te “Wā% pūtukatuka” nāianei (toharite) i roto i te 5 hēkona whakamutunga (10 ngā wā) ki a PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Pehea ki te te uta hahi ki PowerShell?

Pehea ki te tirohia hahi .NET nāianei utaina ki a PowerShell?

Ki te kitea te (Keteroki Global Assembly) ara GAC ​​ki PowerShell?

Clipboard

Pehea ki te tārua i ngā hua ki te papatopenga ki PowerShell?

Pehea ki te tiki i te ihirangi o te papatopenga ki PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Ki te tiki i te hotfixes tāutatia ki PowerShell?
Get-HotFix -ComputerName $computer

Ki te tiki i te hotfixes tāuta i te aroaro o / i muri i te rā motuhake ki 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

Pehea ki te tirohia ki te tāuta i te whakatikawera i te PowerShell?
Get-HotFix -Id KB2965142

Ki te tiki i te hotfixes tāutatia i runga i te rorohiko mamao ki PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Pehea ki te whiwhi mōhiohio whārangikōnae ki PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Ki te tiki i te rahi tūtohutia (MP) mo te whārangikōnae ki PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Ki te hanga i tētahi whārangikōnae (4096 MB) i runga i te (D 🙂 pei ki PowerShell?

Ki te muku i te whārangikōnae i runga i te (C 🙂 pei ki PowerShell?

Maintenance

Me pēhea te kimi i te wehewehenga o te puku ki a PowerShell?

Me pēhea te kimi i te mokowā kōpae o te puku ki te PowerShell?

Up


Files

Pehea ki te whakatuwhera i tētahi kōnae ki PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Ki te pānui i te kōnae ki PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Ki te tuhituhi putanga ki te kōnae ki PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Ki te tiki i te ingoakatoa o te kōnae hōtuhi nāianei ki PowerShell?
$MyInvocation.MyCommand.Path

How ki te kōpeke kōnae kōtui / ki PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Pehea ki te wetekina / ngā kōnae wetetui ki PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Pehea ki te kite i te kōnae i roto i te pūranga ZIP ki PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Pēhea te whakaatu i te rahi o te kōnae i roto i te KB ki PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Ki te kitea ngā kōnae nui iti iho i te 1 GB ki PowerShell ranei?

Pēhea te whakaatu i te ingoa o te kōnae i waho te toronga ki a PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Pehea ki te whakaatu i te toronga o te kōnae ki PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Ki te tiki i te putanga kōnae o te kōnae ki PowerShell?

Ki te tiki i te hae o te kōnae ki PowerShell?
(Get-FileHash $file).Hash

Ki te tiki i te checksum MD5 / SHA1 o te kōnae ki PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Me pēhea te whakaatu i ngā kōnae huna ki a PowerShell?

Me pēhea te kimi, ki te te kōnae he toronga ki PowerShell?

Ki te whakaturia te kōnae rite “Pānui Anake” ki PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Ki te huri i te “LastWriteTime” huanga ki te wiki whakamutunga mo te kōnae ki PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Ki te hanga i tētahi kōnae hōu ki PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

How ki te whakaingoa i tētahi kōnae ki PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Pehea ki te nuinga / puranga whakaingoa kōnae maha ki a PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Pehea ki te muku i te kōnae ki PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Pēhea te whakaatu i te rārangi hou 10 o te kōnae ki PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

How ki te whakawātea e rave rahi kōnae o te kōpaki ki PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Me pēhea te ki te tango rārangi kau i te kōnae ki PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Me pēhea te kimi, ki te vai i te kōnae ki PowerShell?

Ki te tiki i te kōnae hōu / matamua hanga i roto i te kōpaki ki PowerShell?

Ki te tango rārangi tārite i te kōnae ki PowerShell?

Ki te tiki i ngā kōnae hanga atu iti iho ranei i te 1 marama i roto i te kōpaki ki PowerShell?

Ki te tiki i ngā kōnae hanga atu iti iho ranei i te 1 tau i roto i te kōpaki ki PowerShell?

How ki te kaweake i te uara o te tāupe ki te kōnae ki PowerShell?
Set-Content -Path file.txt -Value $variable

Me pēhea te tatau i te maha o ngā kōnae (* .txt) i roto i te kōpaki ki PowerShell?

Pehea ki te rapu i te aho i roto i ngā kōnae maha ki a PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Test'

Pēhea te whakaatu i te rārangi tuatahi / whakamutunga o te kōnae ki PowerShell?

Me pēhea te whakaatu i te maha raina motuhake o te kōnae ki PowerShell?

Me pēhea te tatau i te maha o ngā rārangi o te kōnae ki PowerShell?

Me pēhea te tatau i te maha o ngā pūāhua, me nga kupu a te kōnae ki PowerShell?

Ki te tiki i te kōnae ki PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Pēhea te whakaatu i te ara ki tonu i te te kōnae ki PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

How ki te tārua kotahi kōnae ki te kōpaki ki PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

How ki te tārua kotahi kōnae ki te kōpaki maha ki a PowerShell?

Pehea ki te tārua i ngā kōnae maha ki te kōpaki kotahi ki a 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

Ki te kitea tūmau Global Putumōhio i roto i te Active Directory ki PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Pehea ki te kitea pae i roto i te Active Directory ki PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Pehea ki te kitea i te pūmana rohe nāianei ki PowerShell?
(Get-ADDomainController).HostName

Pehea ki te kitea e nga pūmana rohe katoa i roto i te rohe ki a PowerShell?

Ki te kitea te rahunga AD tukuruatanga ki PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Pehea ki te kitea i te ra tohu mo te ngahere i roto i te Active Directory ki PowerShell?

Ki te tiki kōrero o te ngahere / rohe i roto i te Active Directory ki PowerShell?

Ki te tiki i te ara o te “Ahanoa Mukua” oko i roto i te Active Directory ki PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Me pēhea te whakahohe i te āhuatanga AD Ipu Para i roto i te Active Directory ki PowerShell?

Me Pēhea te Whakaora i te Pūkete AD i te Ipu Para i roto i te Active Directory ki PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Ki te kitea te tūranga FSMO ki PowerShell?

Pehea ki te hono ki te pūmana rohe motuhake ki a PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Pehea ki te tiki i te tūmau takiuru nāianei ki PowerShell?

Founga ki Hono Fakahoko “gpupdate” i runga i te rorohiko ki PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Pehea ki te hanga i tētahi rōpū hou i roto i te Active Directory ki PowerShell?

Ki te tango i te rōpū i roto i te Active Directory ki PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Me pēhea te he kaiwhakamahi ki te rōpū i roto i te Active Directory ki PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Ki te tango i te kaiwhakamahi i tētahi rōpū i roto i te Active Directory ki PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Ki te kitea ngā rōpū kau (me te kore mau melo) i roto i te Active Directory ki PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Me pēhea te tatau rōpū kau (me te kore mau melo) i roto i te Active Directory ki PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Ki te tiki i te mau melo o te rōpū i roto i te Active Directory ki PowerShell?

Ki te tiki i te mau melo o te rōpū ki te mau melo i roto i te recursive Active Directory ki PowerShell?

Me pēhea te tatau i te maha o te mau melo o te rōpū ki te / i waho te mau melo i roto i te recursive Active Directory ki PowerShell?

Users

Pehea ki te whakamahi i te kārimākā i roto i te tātari o “Haere-ADUser” i roto i te Active Directory ki PowerShell?

Kia nuku i te kaiwhakamahi ki tetahi OU i te Active Directory ki PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Pehea ki te kitea e nga mema katoa i te hunga (ōwhanga) mo te kaiwhakamahi ki PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Ki te tiki (ingoa poto / rāpopototia) nga mema mo te kaiwhakamahi ki PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

How ki te whakaingoa i te ingoa (ingoakatoa), (whakaatuingoa), GivenName (ingoatuatahi), a Ingoa (IngoaMutunga) mo te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?

Ki te huri i te Whakaahuatanga, Tari, me te tau Telephone mo te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Ki te whakaturia te rā paunga ki “31/12/2015” “Kaua e” ranei mo te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?

Pehea ki te iriti i te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?
Unlock-ADAccount $samAccountName

Pehea ki te taea ai / mono i te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?

Ki te tango i te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?
Remove-ADUser $samAccountName

Pehea ki te tautuhi anō i te kupuhipa mō te pūkete kotahi kaiwhakamahi i roto i te Active Directory ki PowerShell?

How ki te tautuhi anō i te kupuhipa mō te pūkete e rave rahi kaiwhakamahi (nuinga) i roto i te Active Directory ki PowerShell?

Pehea ki te kitea te rangatira o te kōnae i roto i te Active Directory ki PowerShell?

Ki te kitea te OU (Unit whakahaere) mō te kaiwhakamahi i roto i te Active Directory ki PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Ki te kitea pūkete hauā kaiwhakamahi i roto i te Active Directory ki PowerShell?

Me pēhea te ki te kitea e ngā pūkete pau kaiwhakamahi i roto i te Active Directory ki PowerShell?
Search-ADAccount -AccountExpired

Me pēhea te ki te kitea e ngā pūkete i ponaohia kaiwhakamahi i roto i te Active Directory ki PowerShell?
Search-ADAccount -LockedOut

Pehea ki te kitea i te Sid o te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Pehea ki te tahuri i te ingoa kaiwhakamahi ki Sid i te Active Directory ki PowerShell?

Pehea ki te tahuri i te Sid ki te ingoa kaiwhakamahi i roto i te Active Directory ki PowerShell?

Pehea ki te wahia i te ingoa Distinguished o te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?

Ki te kitea te rā o te hanganga / whakarerekētanga o te pūkete kaiwhakamahi i roto i te Active Directory ki PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Pēhea te whakaatu i te āhuatanga kōwhiringa, me te whakahauanga mō te piha haapiiraa “Kaiwhakamahi” i roto i te Active Directory ki PowerShell?

Ki te tiki i te ara LDAP mo te kaiwhakamahi i roto i te Active Directory ki PowerShell?

Ki te huri i te CN (Mo’oní Ingoa) mo te kaiwhakamahi i roto i te Active Directory ki PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Test Powershell'

Ki te tiki i te Unit whakahaere (OU) matua o te kaiwhakamahi i roto i te Active Directory ki PowerShell?

Ki te tiki i te rangatira o te kaiwhakamahi (nana nei i hanga te pūkete) i roto i te Active Directory ki PowerShell?

How ki te tahuri i te huanga PwdLastSet mo te kaiwhakamahi i roto i te Active Directory ki PowerShell?

Computers

How ki te whakamatautau i te awa haumaru i waenganui i te rorohiko rohe, me te rohe ki a PowerShell?
Test-ComputerSecureChannel

Ki te hanga i te awa haumaru i waenganui i te rorohiko rohe, me te rohe ki a PowerShell?
Test-ComputerSecureChannel -Repair

Pehea ki te mono i te pūkete rorohiko i Active Directory ki PowerShell?
Disable-ADAccount $computer

Me pēhea te ki te kitea rorohiko ki Pūnaha Mahi tauwhāiti i roto i te Active Directory ki PowerShell?

Organizational Unit (OU)

Ki te hanga i tētahi Unit whakahaere (OU) i roto i te Active Directory ki PowerShell?
New-ADOrganizationalUnit -Name 'TEST' -Path 'DC=domain,DC=com'

Ki te tiki Unit whakahaere (OU) kōrero i roto i te Active Directory ki PowerShell?
Get-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Properties *

Ki te huri i te whakaahuatanga o te Unit whakahaere (OU) i roto i te Active Directory ki PowerShell?
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Description 'My description'

Pēhea te whakahohe / mono i te Unit whakahaere (OU) i te mukunga poka i roto i te Active Directory ki PowerShell?

Me pēhea te whakahohe i te mukunga poka mo te Unit katoa whakahaere (OU) i roto i te Active Directory ki PowerShell?

Ki te muku i te Unit whakahaere (OU) tiakina i te mukunga poka i roto i te Active Directory ki PowerShell?

How ki te tahuri i te ingoa Distinguished o te Unit whakahaere (OU) ki Mo’oní ingoa i roto i te Active Directory ki PowerShell?

Pehea ki te hiki Units kau whakahaere (rahi) ki PowerShell?

Pehea ki te tiki i te kaiwhakahaere o te rōpū ki te PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Pehea ki te tango i te v4 wāhitau IP (80.80.228.8) ki a regex ki 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

Ke ke to’o ia i te wāhitau MAC (c0-D9-62-39-61-2D) ki te whakawehe “-” ki regex ki 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

Ke ke to’o ia i te wāhitau MAC (c0: D9: 62: 39: 61: 2D) ki te whakawehe “:” ki regex ki 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

Ke ke to’o ia i te rā (10/02/2015) ki a regex ki PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Ke ke to’o ia i te URL (www.powershell-guru.com) ki a regex ki PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Pehea ki te tango i te īmēra (user@domain.com) ki a regex ki 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

Ke ke to’o “Guru” i te tauira string ki regex ki PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Ke ke to’o “guru.com” i te tauira string ki regex ki PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Pehea ki te tango “powershell-guru.com” i te tauira string ki regex ki PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Ke ke to’o “123” i te tauira string ki regex ki PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Ke ke to’o “$” (tāra tohu) i te tauira string ki regex ki PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

How ki te whakakapi i te huru (* .com) ki tetahi atu (* .fr) i roto i te aho me te regex ki PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Pehea ki te mawhiti i te aho ki regex ki PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

How ki te faahepo i te kohinga o te mahara i te kaikohi paru ki PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Pehea ki te tiki i te rahi RAM o te rorohiko ki te PowerShell?

Up


Date

Pehea ki te tiki i te rā o nāianei ki PowerShell?
Get-Date
[Datetime]::Now

Pēhea te whakaatu i te rā i roto i te rerekē ki PowerShell?

How ki te tahuri i te rā (dateTime) ki te rā (Aho) ki PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

How ki te tahuri i te rā (Aho) ki te rā (dateTime) ki PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Pehea ki te tātai i te rerekētanga (tokomaha o ra, Haora, Minutes, ranei Hēkona) i waenganui i rua ngā rā ki 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

How ki te whakarite ngā rā e rua ki a 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

How ki te kōmaka i te ngohi o ngā rā rite “dateTime” ki PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Me pēhea te tīmata me te mutu i te stopwatch ki PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Ki te tiki i te ra o te wiki ki a PowerShell nāianei?
(Get-Date).DayOfWeek #Sunday

Ki te tiki te rā o te inanahi ki PowerShell?
(Get-Date).AddDays(-1)

Ki te tiki i te maha o nga ra i roto i te marama (i roto i te Hui-tanguru 2015) ki PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Pehea ki te mohio ki te tau ekeeke ki PowerShell?
[DateTime]::IsLeapYear(2015)

Pehea ki te hiki wa rohe ki PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Pehea ki te whakawaehere (ki te hōputu ASCII), me te Pūwhiwhi he URL ki PowerShell?

He aha nga ritenga o whakahau whatunga taketake ki PowerShell?

Me pēhea te ki te tiki wāhitau IP ki PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Pehea ki te mono IP v6 wāhitau (IPv6) ki PowerShell?

Pehea ki te whakamana i te v4 wāhitau IP (IPv4) ki PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Ngā huarahi hei rapu wāhitau te IP waho ki a PowerShell?

Ki te kitea te Pūtaurima i te wāhitau IP ki PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Ki te kitea te wāhitau IP i te Pūtaurima ki PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Pehea ki te kitea i te FQDN i te Pūtaurima ki PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Ki te kitea te whirihoranga whatunga (Ip, Ipurangiroto, Gateway, me te DNS) ki PowerShell?

Ki te kitea te wāhitau MAC ki a PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Pehea ki te hopu i tētahi rorohiko ki PowerShell?

Pehea ki te tirohia ki te tūhono i te rorohiko ki te ipurangi ki PowerShell?

Pehea ki te mahi i te “Whois” tirohia hoki te paetukutuku ki PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Me pēhea te ki te tiki kōrero o te IP tūmatanui (Geolocation) ki PowerShell?

Me pēhea te kimi, ki te he tuwhera he tauranga / katia ki PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Pehea ki te mahi i “tracert” ki PowerShell?
Test-NetConnection www.google.com -TraceRoute

Me pēhea te ki te whakatika i te kōtaha hononga whatunga te kāinga ki PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Pehea ki te whakaatu i te hononga tauranga TCP ki PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

How ki te whakapoto i te URL roa ki te URL iti ki PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Me pēhea te ki te tiki tautuhinga takawaenga ki PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Pehea ki te tirohia i te keteroki DNS i runga i te rorohiko rohe ki a PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Pēhea te ūkui i te keteroki DNS i runga i te rorohiko rohe ki a PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Pehea ki te ūkui i te keteroki DNS i runga i rorohiko mamao ki PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Ki te pānui i te kōnae i te mano ki a PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

How ki te whakaputa i te kupuhipa matapōkere ki PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Ki te huri i te kupuhipa rohe mo te kaiwhakahaere i runga i te tūmau mamao ki PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Ki te kitea te rā paunga kupuhipa o te pūkete i roto i te Active Directory ki PowerShell?

Up


Printers

How ki te whakarārangi i te pūreretā katoa mo te tūmau motuhake ki PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

How ki te whakarārangi i te tauranga katoa mo te tūmau motuhake ki PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Pehea ki te huri i te kōrero / wāhi o te pūreretā ki PowerShell?

How ki te e pokekore ai (whakakore mahi katoa) ki te pūreretā ki PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

How ki te tā i te whārangi whakamātau mo te pūreretā ki PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Ki te tiki tā rārangi mō ngā pūreretā ki PowerShell?

Up


Regedit

Read

How ki te hiki pununga honé rēhita ki PowerShell?
Get-ChildItem -Path Registry::

Ki te tiki uara rēhita me ngā momo uara ki PowerShell?

Pehea ki te hiki kīroto kī rēhita ki PowerShell?

Pehea ki te hiki kīroto kī rēhita i roto i te ara recursive ki PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Ki te kitea kīroto ki te ingoa motuhake ki PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Pehea ki te hoki noa te ingoa o te kīroto rēhita ki PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

How ki te hiki uara rēhita ki PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Me pēhea te ki te pānui i te uara rēhita motuhake ki a PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Ki te pānui i te uara rēhita motuhake i runga i te rorohiko mamao ki PowerShell?

Write

Ki te hanga i tētahi kī rēhita hou ki a PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Pehea ki te hanga i tētahi uara rēhita ki PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Me pēhea te ki te whakarerekē i te uara rēhita tīariari ki a PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Ki te muku i te uara rēhita ki PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Ki te muku i te kī rēhita ki PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Me pēhea te ki te whakamātau i ki te vai i te kī rēhita ki PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

How ki te whakamātau i ki te vai i te uara rēhita ki PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Ki te tango pūāhua mokowā-ma i te timatanga o te aho ki PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Ki te tango pūāhua mokowā-ma i te pito o te aho ki PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Ki te tango pūāhua mokowā-ma (timata me te mutu) o te aho ki PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

How ki te tahuri i te aho ki te take runga ki a PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

How ki te tahuri i te aho ki te raro take ki a PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Ki te tīpako i te Ahoroto “PowerShell” o te aho “PowerShellGuru” ki PowerShell?
$string.Substring(0,10)

Pehea ki te tīpako i te Ahoroto “Guru” o te aho “PowerShellGuru” ki PowerShell?
$string.Substring(10)

Pehea ki te tīpako i te tau “123” o “PowerShell123Guru” ki PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Ki te tiki i te taupū-e hāngai ana kore o “Guru” o te aho “PowerShellGuru” ki PowerShell?
$string.IndexOf('Guru') # 10

Me pēhea te kimi, ki te he korenga ranei kau ki PowerShell he aho?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Me pēhea te kimi, ki te he te aho i whakakahore, kau, ngā anake o ngā pūāhua mokowā-ma ki a PowerShell ranei?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Me pēhea te kimi, ki te kei te aho i tētahi reta motuhake ki PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Pehea ki te hoki i te roa o te aho ki PowerShell?
$string.Length

Pehea ki te CONCATENATE aho e rua ki a PowerShell?

How ki te ōrite hoki tetahi ranei e rave rahi taiapa “[]” i roto i te aho me te PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Pehea ki te ōrite hoki tetahi ranei e rave rahi te ‘”()” i roto i te aho me te PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Pehea ki te ōrite hoki tetahi ranei e rave rahi taiapa mingimingi “{}” i roto i te aho me te PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

How ki te ōrite hoki tetahi ranei e rave rahi taiapa koki “<>” i roto i te aho me te PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Pehea ki te ōrite tetahi reta pūriki (ABC) i roto i te aho me te PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

How ki te ōrite tetahi upperletters (ABC) i roto i te aho me te PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

How ki te ōrite “[p” (p take raro) i roto i te aho me te PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Pehea ki te ōrite “[P” (P take runga) i roto i te aho me te PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

How ki te whakakapi i te raina ki tetahi aho ki PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Pehea ki te tahuri i te mahi wehenga ki te aho (ōrau) ki PowerShell?
(1/2).ToString('P')

Pehea ki te kōmaka aho kei tau ki PowerShell?

Pehea ki te tīpako i te kupu whakamutunga o te kupu ki a PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ')[-1] # Returns Powershell

Ki te tiki i te kupu nui o te kupu ki a PowerShell?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Powershell

Pehea ki te tatau i te maha o ngā wā i te aho he hakari i roto i te kupu ki a PowerShell?
$sentence = 'test test test Powershell'
[regex]::Matches($sentence, 'test').Count # Returns 3

Pehea ki te tārua ia huru i roto i te aho ki te ngohi pūāhua ki PowerShell?

How ki te tahuri i te pukapuka tuatahi ki te pūmatua o te aho ki PowerShell?

How ki te papa (mahue tika ranei) he aho ki PowerShell?

Pehea ki te whakawaehere ka Pūwhiwhi he aho ki Base64 ki PowerShell?

How ki te tahuri i te tau (ki a i) rua ki PowerShell?

Pehea ki te hoki noa te kōpaki matua whakamutunga i roto i te ara ki PowerShell?

Founga ke tau foki te tūemi whakamutunga anake i roto i te ara ki PowerShell?

Up


Math

How ki te hiki i te tikanga o te piha haapiiraa System.Math ki PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Pehea ki te hoki i te uara pū ki a PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Pehea ki te hoki i te koki nei aho ko te maha i āta tohua ki a PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Pehea ki te hoki i te uara tuanui ki a PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Pehea ki te hoki i te uara papa ki a PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Pehea ki te hoki i te taiao (turanga e) taupū kōaro o te tau i tohua ki te PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

Pehea ki te hoki i te taupū kōaro turanga 10 o te tau i tohua ki te PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

Founga ke tau foki i te mōrahi o te rua ngā uara ki PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Pehea ki te hoki i te iti o te rua ngā uara ki PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Founga ke tau foki he tau whakaarahia ki te mana tohua ki PowerShell?
[Math]::Pow(2,4) #Returns 16

Founga ke tau foki te uara ira ki te uara wāhi tata ki a PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Pehea ki te hoki ki te wāhi o te tau ā-ira tohua ki PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Pehea ki te hoki ki te pakiaka tapawha o te tau i tohua ki te PowerShell?
[Math]::Sqrt(16) #Returns 4

Pehea ki te hoki i te tamau PI ki PowerShell?
[Math]::Pi #Returns 3,14159265358979

Pehea ki te hoki i te turanga tūturu pākoki (tonu e) ki PowerShell?
[Math]::E #Returns 2,71828182845905

Me pēhea te kimi, ki te he ara ranei rerekē ki PowerShell he maha?
[bool]($number%2)

Up


Hashtables

Ki te hanga i tētahi hashtable kau ki PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Ki te hanga i te hashtable ki ngā tūemi ki PowerShell?

Ki te hanga i tētahi hashtable kōmaka i te matua / ingoa (papakupu whakahau) ki te tūemi ki PowerShell?

Me pēhea te tūemi (matua uara-rua) ki te hashtable ki PowerShell?
$hashtable.Add('Key3', 'Value3')

Ki te tiki i te uara motuhake o te hashtable ki PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Pehea ki te tiki i te uara iti rawa o te hashtable ki PowerShell?

Pehea ki te tiki i te uara mōrahi o te hashtable ki PowerShell?

Pehea ki te whakakē i ngā tūemi i roto i te hashtable ki PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Me pēhea te ki te tango i ngā tūemi i roto i te hashtable ki PowerShell?
$hashtable.Remove('Key1')

Pēhea te ūkui i te hashtable ki PowerShell?
$hashtable.Clear()

Me pēhea te kimi i te aroaro o te matua / uara motuhake i roto i te hashtable ki PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

How ki te kōmaka i te / uara matua i roto i te hashtable ki PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Pehea ki te hanga i tētahi ngohi kau ki PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Pehea ki te waihanga i tētahi ngohi ki te tūemi ki PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Me pēhea te tūemi ki te ngohi ki PowerShell?
$array += 'D'
[void]$array.Add('D')

Pehea ki te whakarerekē i te tūemi i roto i te ngohi ki PowerShell?
$array[0] = 'Z' # 1st item[0]

Me pēhea te kimi i te rahi o te ngohi ki PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

How ki te tiki i tetahi tūemi / e rave rahi tūemi katoa / i roto i te ngohi ki PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Ki te tango tūemi kau i roto i te ngohi ki PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Me pēhea te kimi, ki te vai i te tūemi i roto i te ngohi ki PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Pehea ki te kitea i te tau taupū o te tūemi i roto i te ngohi ki PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Pehea ki te whakataka i te raupapa o ngā tūemi i roto i te ngohi ki PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Pehea ki te whakaputa i te tūemi matapōkere i te ngohi ki PowerShell?
$array | Get-Random

Pehea ki te kōmaka i te ngohi i roto i te piki ake / heke ara ki PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Pehea ki te tatau i te maha o ngā tūemi i roto i te ngohi ki PowerShell?
$array.Count

Me pēhea te he ngohi ki tetahi ki a PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Pehea ki te kitea tārua i te ngohi ki PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Me pēhea te ki te tango tārua i te ngohi ki PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Pehea ki te waihanga i tētahi ngohi ki te tūemi tīmata ki te kuhimua (“user01”, “user02”, … “user10”) ki PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Pehea ki te whakarārangi RMU o te kaiwhakamahi AD ki PowerShell?
(Get-Acl -Path "AD:\$dn").Access

How ki te hiki RMU o te kōpaki ki PowerShell?
(Get-Acl -Path C:\scripts).Access

How ki te hiki i ngā tāurunga motuhake whakaaetanga RMU (kaiwhakamahi ranei rōpū) o te AD kaiwhakamahi ki PowerShell?

Up


Variables

He aha ngā momo i te raraunga tino noa ki PowerShell?

Pehea ki te kitea e te iti me te uara mōrahi mō ētahi taurangi momo ki PowerShell?

How ki te whakamatautau i te Momoraraunga ki PowerShell?

Pehea ki te hanga i tētahi Here-Aho ao te ki PowerShell?

Ki te hanga i te ao te ki PowerShell?
$powershellGuru = 'Hello'

Pehea ki te hanga i tētahi tāupe tamau ki PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Ki te hanga i tētahi ao te ao ki a PowerShell?
$Global:powershellGuru = 'Hello'

Ki te pānui i te tāupe ki PowerShell?