FAQ POWERSHELL ING BASA JAWA

By | April 17, 2015

translated-javanese


beta-v2-0


Konsep: Pitakonan sing paling kerep ditakokake babagan PowerShell.

Sampeyan bisa nggunakake dhaftar iki ing cara sing beda:

  • Kanggo nyalin/nempelake printah nyang script
  • Kanggo ndelok cepet sintaksis saka printah tartamtu
  • Kanggo nambah wawasan teknik sampeyan
  • Kanggo nemokake printah anyar
  • Kanggo nyiapake wawancara gawean

Dianyari
07 Juli, 2015
Pengarang Steve Renard
Sumber javanese.powershell-guru.com
Kategori
75
Pitakonan
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

Piye cara nemtokake versi PowerShell ku?

Piye cara nglakokake PowerShell ing versi liyane kanggo backward-compatibility?
powershell.exe -Version 2.0

Piye carane njaluk versi Powershell paling sithik (3.0 lan luwih) ing script nganggo PowerShell?
#Requires -Version 3.0

Piye carane njaluk hak akses administratif kanggo script nganggo PowerShell?

Piye carane ngecek parameter script nganggo PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Piye carane entuk informasi kanggo user saiki nganggo PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Piye carane nggawe, ngowahi lan ngunggah profil nganggo PowerShell?

Piye carane nggawe jeda 5 detik / menit ing script nganggo PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Piye carane entuk wektu boot pungkasan nganggo PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Piye carane njaluk jenis akselerator nganggo PowerShell?

Piye carane ndhaftar program startup nganggo PowerShell?

Piye carane un-instal aplikasi nganggo Powershell?

Piye carane njupuk gambar saka kabeh desktop utawa jendhela aktif nganggo PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Piye carane entuk cacahe pesen kanggo antrian MSMQ nganggo PowerShell?

Piye carane nyetel kebijakan eksekusi nganggo PowerShell?

Piye carane nggawe shortcut nganggo PowerShell?

Piye carane nge-pin utawa un-pin program nyang taskbar nganggo PowerShell?

Piye carane mbukak Windows Explorer nganggo PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Piye carane ndhaftar driver-driver piranti nganggo PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Piye carane nggawe GUID nganggo PowerShell?

Piye carane entuk lokasi direktori sawentara kanggo user saiki nganggo PowerShell?
[System.IO.Path]::GetTempPath()

Piye cara nggabungake path lan anak path dadi path tunggal nganggo PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Piye carane ndhaftar kabeh cmdlets “Get-*” nganggo PowerShell?
Get-Command -Verb Get

Piye carane ndhaftar folder sistem khusus nganggo PowerShell?

Piye carane nyusun file ISO/VHD nganggo PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Piye carane ngecek versi .NET Framework sing diinstal nganggo PowerShell?

Piye carane ngecek yen .NET Framework versi 4.5 diinstal nganggo PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Piye carane miwiti lan mungkasi transcript (kanggo nggawe catetan sesi Windows PowerShell) nganggo PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Piye carane ngganti direktori saiki nyang lokasi tartamtu nganggo PowerShell?
Set-Location -Path 'C:\scripts'

Piye carane mbusak layar nganggo PowerShell?
Clear-Host
cls # Alias

Piye carane ngganti resolusi tampilan nganggo PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Piye carane nyetel jendhela “full screen” nganggo PowerShell?
mode.com 300

Piye carane entuk dimensi (ambane lan dawane) gambar nganggo PowerShell?

Piye carane entuk kunci produk Windows nganggo PowerShell?

Perfmon

Piye carane entuk “% Processor Time” (rata-rata) saiki ing 5 detik pungkasan (kaping 10) nganggo PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Piye carane ngundhuh rakitan-rakitan nganggo PowerShell?

Piye carane ngecek rakitan .NET saiki sing diundhuh nganggo PowerShell?

Piye cara nemokake path GAC (Global Assembly Cache) nganggo PowerShell?

Clipboard

Piye carane nyalin hasil nyang clipboard nganggo PowerShell?

Piye carane entuk isine clipboard nganggo PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Piye carane entuk hotfix sing diinstal nganggo PowerShell?
Get-HotFix -ComputerName $computer

Piye carane entuk hotfix sing diinstal sadurunge/sawise tanggal tartamtu nganggo 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

Piye carane ngecek yen hotfix diinstal nganggo PowerShell?
Get-HotFix -Id KB2965142

Piye carane entuk hotfix sing diinstal ing komputer remote nganggo PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Piye carane entuk informasi Pagefile nganggo PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Piye carane entuk ukuran sing dianjurake (MB) kanggo Pagefile nganggo PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Piye carane nggawe Pagefile (4096 MB) ing drive (D:) nganggo PowerShell?

Piye carane ngilangi Pagefile ing drive (C:) nganggo PowerShell?

Maintenance

Piye carane ngecek fragmentasi drive nganggo PowerShell?

Piye carane ngecek ruang disk drive nganggo PowerShell?

Up


Files

Piye carane mbukak file nganggo PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Piye carane maca file nganggo PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Piye carane nulis output nyang file nganggo PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Piye carane entuk jeneng komplite file script saiki nganggo PowerShell?
$MyInvocation.MyCommand.Path

Piye carane ngompress/zip file-file nganggo PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Piye carane uncompress/Unzip file-file nganggo PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Piye carane ndelok file ing arsip ZIP nganggo PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Piye cara nampilake ukuran file ing KB nganggo PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Piye cara nemokake file sing luwih gedhe utawa kurang saka 1 GB nganggo PowerShell?

Piye cara nampilake jeneng file tanpa ekstensi nganggo PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Piye cara nampilake ekstensi file nganggo PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Piye carane entuk versine file saka sawijining file nganggo PowerShell?

Piye carane entuk hash saka file nganggo PowerShell?
(Get-FileHash $file).Hash

Piye carane entuk checksum MD5/SHA1 file nganggo PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Piye cara nampilake hidden file nganggo PowerShell?

Piye carane ngecek yen file duwe ekstensi nganggo PowerShell?

Piye carane nyetel file dadi “Read Only” nganggo PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Piye carane ngganti atribut “LastWriteTime” nyang minggu wingi kanggo sawijining file nganggo PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Piye carane nggawe file anyar nganggo PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Piye carane ngganti jeneng file nganggo PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Piye carane bulk/batch rename pirang-pirang file nganggo PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Piye carane ngilangi file nganggo PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Piye cara nampilake 10 garis pungkasan file nganggo PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Piye carane mbukak blokir pirang-pirang file saka folder nganggo PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Piye carane mbusak baris kosong saka file nganggo PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Piye carane ngecek yen file kuwi ana nganggo PowerShell?

Piye carane entuk file sing digawe paling anyar/lawas ing folder nganggo PowerShell?

Piye carane mbusak duplikat baris saka file nganggo PowerShell?

Piye carane entuk file sing digawe luwih utawa kurang saka sesasi ing folder nganggo PowerShell?

Piye carane entuk file sing digawe luwih utawa kurang saka setaun ing folder nganggo PowerShell?

Piye carane ngekspor biji variabel nyang file nganggo PowerShell?
Set-Content -Path file.txt -Value $variable

Piye carane ngitung cacahe file (*.txt) ing folder nganggo PowerShell?

Piye carane nggoleki string ing pirang-pirang file nganggo PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

Piye cara nampilake baris pisanan/pungkasan saka file nganggo PowerShell?

Piye cara nampilake cacahe baris tartamtu saka file nganggo PowerShell?

Piye carane ngitung cacahe baris saka file nganggo PowerShell?

Piye carane ngitung cacahe karakter lan tembung saka file nganggo PowerShell?

Piye carane ngundhuh file nganggo PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Piye cara nampilake path komplit saka file nganggo PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Piye carane nyalin siji file nyang folder nganggo PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Piye carane nyalin siji file nyang pirang-pirang folder nganggo PowerShell?

Piye cara nyalin pirang-pirang file nyang sak folder nganggo 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

Piye cara nemokake server Global Catalog ing Active Directory nganggo PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Piye cara nemokake situs ing Active Directory nganggo PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Piye cara nemokake kontroler domain saiki nganggo PowerShell?
(Get-ADDomainController).HostName

Piye cara nemokake kabeh kontroler domain ing domain nganggo PowerShell?

Piye cara nemokake gagale replikasi AD nganggo PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Piye cara nemokake tombstone lifetime kanggo forest ing Active Directory nganggo PowerShell?

Piye carane entuk rinciane forest/domain ing Active Directory nganggo PowerShell?

Piye carane entuk path saka kontainer “Deleted Objects” ing Active Directory nganggo PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Piye cara ngaktifake fitur AD Recycle Bin ing Active Directory nganggo PowerShell?

Piye cara mbalekake Akun AD saka Recycle Bin ing Active Directory nganggo PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Piye cara nemokake peran FSMO nganggo PowerShell?

Piye carane nyambung nyang kontroler domain tartamtu nganggo PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Piye carane entuk logon server saiki nganggo PowerShell?

Piye cara nglakokake “gpupdate” ing komputer nganggo PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Piye carane nggawe grup anyar ing Active Directory nganggo PowerShell?

Piye carane ngilangi grup ing Active Directory nganggo PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Piye carane nambah user nyang grup ing Active Directory nganggo PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Piye carane ngilangi user saka grup ing Active Directory nganggo PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Piye cara nemokake grup kosong (tanpa anggota) ing Active Directory nganggo PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Piye carane ngitung grup kosong (tanpa anggota) ing Active Directory nganggo PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Piye carane entuk anggota saka grup ing Active Directory nganggo PowerShell?

Piye carane entuk anggota saka grup sing ana anggota rekursif ing Active Directory nganggo PowerShell?

Piye carane ngitung cacahe anggota grup sing ana/tanpa anggota rekursif ing Active Directory nganggo PowerShell?

Users

Piye cara nggunakake wildcard ing filter “Get-ADUser” ing Active Directory nganggo PowerShell?

Piye carane mindhah user nyang OU liyane ing Active Directory nganggo PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Piye cara nemokake kabeh anggota sing (Nested) kanggo user nganggo PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Piye carane entuk anggota (jeneng cendhak/disingkat) kanggo user nganggo PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Piye carane ngganti Name (Jeneng Komplit), (Jeneng sing Tampil), GivenName (Jeneng Ngarep), lan Surname (Jeneng Mburi) kanggo akun user ing Active Directory nganggo PowerShell?

Piye carane ngganti Deskripsi, Kantor, lan Nomer telepon kanggo akun user ing Active Directory nganggo PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Piye carane nyetel tanggal kadaluwarsa nganti “31/12/2015” utawa “Never” kanggo akun user ing Active Directory nganggo PowerShell?

Piye carane mbukak akun user ing Active Directory nganggo PowerShell?
Unlock-ADAccount $samAccountName

Piye cara ngaktifake/mateni akun user ing Active Directory nganggo PowerShell?

Piye carane ngilangi akun user ing Active Directory nganggo PowerShell?
Remove-ADUser $samAccountName

Piye carane ngreset sandhi kanggo sak akun user ing Active Directory nganggo PowerShell?

Piye carane ngreset sandhi kanggo pirang-pirang akun user (bulk) ing Active Directory nganggo PowerShell?

Piye cara nemokake sapa sing duweni file ing Active Directory nganggo PowerShell?

Piye cara nemokake OU (Organizational Unit) kanggo user ing Active Directory nganggo PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Piye cara nemokake akun user sing ora aktif ing Active Directory nganggo PowerShell?

Piye cara nemokake akun user sing kadaluwarsa ing Active Directory nganggo PowerShell?
Search-ADAccount -AccountExpired

Piye cara nemokake akun user sing dikunci ing Active Directory nganggo PowerShell?
Search-ADAccount -LockedOut

Piye cara nemokake SID akun user ing Active Directory nganggo PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Piye carane ngganti username dadi SID ing Active Directory nganggo PowerShell?

Piye carane ngganti SID dadi username ing Active Directory nganggo PowerShell?

Piye carane misah Distinguished Name akun user ing Active Directory nganggo PowerShell?

Piye cara nemokake tanggal akun user digawe/diowahi ing Active Directory nganggo PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Piye cara nampilake properti pilihan lan wajib kanggo kelas “User” ing Active Directory nganggo PowerShell?

Piye carane entuk path LDAP kanggo user ing Active Directory nganggo PowerShell?

Piye carane ngganti CN (Canonical Name) kanggo user ing Active Directory nganggo PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

Piye carane entuk Organizational Unit (OU) parent sawijining user ing Active Directory nganggo PowerShell?

Piye carane entuk pemilike user (sing nggawe akun) ing Active Directory nganggo PowerShell?

Piye carane ngganti atribut pwdLastSet kanggo user ing Active Directory nganggo PowerShell?

Computers

Piye carane nguji secure channel antarane komputer lokal lan domain nganggo PowerShell?
Test-ComputerSecureChannel

Piye carane ndandani secure channel antarane komputer lokal lan domain nganggo PowerShell?
Test-ComputerSecureChannel -Repair

Piye carane mateni akun komputer ing Active Directory nganggo PowerShell?
Disable-ADAccount $computer

Piye cara nemokake komputer sing duwe Sistem Operasi tartamtu ing Active Directory nganggo PowerShell?

Organizational Unit (OU)

Piye carane nggawe Organizational Unit (OU) ing Active Directory nganggo PowerShell?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

Piye carane entuk rinciane Organizational Unit (OU) ing Active Directory nganggo PowerShell?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

Piye carane ngganti deskripsi saka Organizational Unit (OU) ing Active Directory nganggo PowerShell?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

Piye cara ngaktifake/mateni Organizational Unit (OU) saka pambusakan sing ora sengaja ing Active Directory nganggo PowerShell?

Piye cara ngaktifake pambusakan sing ora sengaja kanggo kabeh Organizational Unit (OU) ing Active Directory nganggo PowerShell?

Piye carane ngilangi Organizational Unit (OU) sing dilindungi saka pambusakan ora sengaja ing Active Directory nganggo PowerShell?

Piye carane ngganti Distinguished Name saka sawijining Organizational Unit (OU) dadi Canonical Name ing Active Directory nganggo PowerShell?

Piye carane ndhaftar Organizational Units (OUs) sing kosong nganggo PowerShell?

Piye carane entuk manajer grup nganggo PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Piye carane ekstrak alamat IP v4 (80.80.228.8) nganggo Regex nganggo 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

Piye carane ekstrak alamat MAC (C0-D9-62-39-61-2D) nganggo pamisah “-” karo Regex nganggo 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

Piye carane ekstrak alamat MAC (C0: D9: 62: 39: 61: 2D) nganggo pamisah “:” karo Regex nganggo 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

Piye carane ekstrak tanggal (10/02/2015) nganggo Regex nganggo PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Piye carane ekstrak alamat URL (www.powershell-guru.com) nganggo Regex nganggo PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Piye carane ekstrak email (user@domain.com) nganggo Regex nganggo 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

Piye carane ekstrak “guru” saka conto string nganggo Regex nganggo PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Piye carane ekstrak “guru.com” saka conto string nganggo Regex nganggo PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Piye carane ekstrak “powershell-guru.com” saka conto conto string nganggo Regex nganggo PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Piye carane ekstrak “123” saka conto conto string nganggo Regex nganggo PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Piye carane ekstrak “$” (tandha dolar) saka conto conto string nganggo Regex nganggo PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Piye carane ngganti karakter (*.com) karo (*.fr) liyane ing sawijining string nganggo Regex nganggo PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Piye cara ngetokake string nganggo Regex nganggo PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Piye carane meksa pangumpulan memori kanthi garbage collector nganggo PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Piye carane entuk ukurane RAM komputer nganggo PowerShell?

Up


Date

Piye carane entuk tanggal saiki nganggo PowerShell?
Get-Date
[Datetime]::Now

Piye cara nampilake tanggal ing format sing beda nganggo PowerShell?

Piye carane ngganti tanggal (Datetime) dadi tanggal (String) nganggo PowerShell?

Piye carane ngganti tanggal (String) dadi tanggal (Datetime) nganggo PowerShell?

Piye cara ngitung selisihe (cacahe Dina, Jam, Menit, utawa Detik) antarane rong tanggal nganggo 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

Piye cara mbandhingake rong tanggal nganggo 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

Piye cara ngurutake array saka tanggal minangka “Datetime” nganggo PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Piye cara miwiti lan mungkasi stopwatch nganggo PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Piye carane entuk dina saiki saka minggu nganggo PowerShell?
(Get-Date).DayOfWeek #Sunday

Piye carane entuk tanggal ndek wingi nganggo PowerShell?
(Get-Date).AddDays(-1)

Piye carane entuk cacahe dina ing sawijining sasi (ing Februari 2015) nganggo PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Piye cara ngerteni taun kabisat nganggo PowerShell?
[DateTime]::IsLeapYear(2015)

Piye carane ndhaftar zona wektu nganggo PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Piye carane encode (nyang format ASCII) lan decode URL nganggo PowerShell?

Apa sing setara saka perintah jaringan asli karo PowerShell?

Piye carane entuk alamat IP nganggo PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Piye carane mateni alamat IP V6 (IPv6) nganggo PowerShell?

Piye cara ngesahake alamat IP v4 (IPv4) nganggo PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Piye cara nemokake alamat IP eksternal nganggo PowerShell?

Piye cara nemokake Hostname saka alamat IP nganggo PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Piye cara nemokake alamat IP saka Hostname nganggo PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Piye cara nemokake FQDN saka Hostname nganggo PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Piye cara nemokake konfigurasi jaringan (Ip, Subnet, Gateway, lan DNS) nganggo PowerShell?

Piye cara nemokake alamat MAC nganggo PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Piye carane nge-ping komputer nganggo PowerShell?

Piye carane ngecek yen komputer nyambung nyang internet nganggo PowerShell?

Piye cara nglakokake “whois” lookup kanggo website nganggo PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Piye cara entuk rinciane IP publik (Geolocation) nganggo PowerShell?

Piye carane ngecek yen port mbukak/nutup nganggo PowerShell?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Piye cara nglakokake “tracert” nganggo PowerShell?
Test-NetConnection www.google.com -TraceRoute

Piye carane ndandani profil sambungan home network nganggo PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Piye cara nampilake sambungan port TCP nganggo PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Piye cara nyendhakake URL sing dawa dadi URL cilik nganggo PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Piye carane entuk setelan proxy nganggo PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Piye carane ngecek cache DNS ing komputer lokal nganggo PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Piye carane mbusak DNS cache ing komputer lokal nganggo PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Piye carane mbusak DNS cache ing komputer remote nganggo PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Piye carane maca Hosts file nganggo PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Piye cara ngasilake sandhi acak nganggo PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Piye carane ngganti sandhi lokal kanggo administrator ing remote server nganggo PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Piye cara nemokake tanggal kadaluwarsa sandhi sawijining akun ing Active Directory nganggo PowerShell?

Up


Printers

Piye carane ndhaftar kabeh printer kanggo server tartamtu nganggo PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Piye carane ndhaftar kabeh port kanggo server tartamtu nganggo PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Piye carane ngganti komentar/lokasi kanggo printer nganggo PowerShell?

Piye cara ngresikake (mbatalake kabeh tugas) kanggo printer nganggo PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Piye carane nyetak test page kanggo printer nganggo PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Piye carane entuk antrian cetak kanggo printer nganggo PowerShell?

Up


Regedit

Read

Piye carane ndhaftar hive registry nganggo PowerShell?
Get-ChildItem -Path Registry::

Piye carane entuk nilai registry lan jenise nilai nganggo PowerShell?

Piye carane ndhaftar key subkey registry nganggo PowerShell?

Piye carane ndhaftar key subkey registry ing cara rekursif nganggo PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Piye cara nemokake subkey-subkey sing jenenge tartamtu nganggo PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Piye cara mbalekake mung jenenge subkeys registry nganggo PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Piye carane ndhaftar nilai registry nganggo PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Piye carane maca nilai registry tartamtu nganggo PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Piye carane maca nilai registry tartamtu ing komputer remote nganggo PowerShell?

Write

Piye carane nggawe key registry anyar nganggo PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Piye carane nggawe nilai registry nganggo PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Piye carane ngowahi nilai registry sing wis ana nganggo PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Piye carane ngilangi nilai registry nganggo PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Piye carane ngilangi key registry nganggo PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Piye carane ngetes yen key registry kuwi ana nganggo PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Piye carane ngetes yen nilai registry kuwi ana nganggo PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Piye carane mbusak karakter white-space saka wiwitane string nganggo PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Piye carane mbusak karakter white-space saka pungkasane string nganggo PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Piye carane mbusak karakter white-space saka (wiwitan lan pungkasan) string nganggo PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Piye carane ngganti string dadi huruf gedhe nganggo PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Piye carane ngganti string dadi huruf cilik nganggo PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Piye carane milih substring “PowerShell” saka string “PowershellGuru” nganggo PowerShell?
$string.Substring(0,10)

Piye carane milih substring “Guru” saka string “PowershellGuru” nganggo PowerShell?
$string.Substring(10)

Piye carane milih nomer “123” saka “Powershell123Guru” nganggo PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Piye carane entuk indeks basis nol saka “Guru” saka string “PowershellGuru” nganggo PowerShell?
$string.IndexOf('Guru') # 10

Piye carane ngecek yen string iku null utawa kosong nganggo PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Piye carane ngecek yen string iku null, kosong, utawa isine mung karakter white-space nganggo PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Piye carane ngecek yen string ngemot aksara tartamtu nganggo PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Piye cara mbalekake dawa string nganggo PowerShell?
$string.Length

Piye cara nggabungake rong string nganggo PowerShell?

Piye cara nyocokkake siji utawa pirang-pirang tandha kurung gedhe “[ ]” ing string nganggo PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Piye cara nyocokkake siji utawa pirang-pirang tandha kurung “( )” ing string nganggo PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Piye cara nyocokkake siji utawa pirang-pirang tandha kurung kriting “{ }” ing string nganggo PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Piye cara nyocokkake siji utawa pirang-pirang tandha kurung sudut “< >” ing string nganggo PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Piye cara nyocokkake sembarang huruf cilik (abc) ing string nganggo PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Piye cara nyocokkake sembarang huruf gedhe (ABC) ing string nganggo PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Piye cara nyocokkake “[p” (p huruf cilik) ing string nganggo PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Piye cara nyocokkake “[P” (P huruf gedhe) ing string nganggo PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Piye carane ngganti baris karo baris liyane nganggo PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Piye carane ngganti operasi divisi nyang string (persentase) nganggo PowerShell?
(1/2).ToString('P')

Piye cara ngurutake string sing isine nomer nganggo PowerShell?

Piye carane milih tembung pungkasan saka ukara nganggo PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

Piye carane entuk tembung paling gedhe saka ukara nganggo PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

Piye carane ngitung cacahe string sing ana ing ukara nganggo PowerShell?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

Piye carane nyalin saben karakter ing string nyang array karakter nganggo PowerShell?

Piye carane ngganti huruf kapisan dadi huruf gedhe saka string nganggo PowerShell?

Piye carane pad (kiwa utawa tengen) string nganggo PowerShell?

Piye carane encode lan decode string nyang Base64 nganggo PowerShell?

Piye carane ngganti nomer (menyang lan saka) binary nganggo PowerShell?

Piye cara mbalekake mung folder induk pungkasan ing path nganggo PowerShell?

Piye cara mbalekake mung item pungkasan ing path nganggo PowerShell?

Up


Math

Piye carane ndhaftar metode System.Math class nganggo PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Piye cara mbalekake biji absolut nganggo PowerShell?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Piye cara mbalekake sudut sing sinuse angka tartamtu nganggo PowerShell?
[Math]::ASin(1) #Returns 1,5707963267949

Piye cara mbalekake biji ceiling nganggo PowerShell?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Piye cara mbalekake biji floor nganggo PowerShell?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Piye cara mbalekake logaritma (base e) natural saka angka tartamtu nganggo PowerShell?
[Math]::Log(4) #Returns 1,38629436111989

Piye cara mbalekake logaritma base 10 saka angka tartamtu nganggo PowerShell?
[Math]::Log10(4) #Returns 0,602059991327962

Piye cara mbalekake maksimum saka 2 nilai nganggo PowerShell?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Piye cara mbalekake minimum saka 2 nilai nganggo PowerShell?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Piye cara mbalekake angka sing diangkat dadi daya tartamtu nganggo PowerShell?
[Math]::Pow(2,4) #Returns 16

Piye cara mbalekake biji desimal nyang biji integral paling cedhak nganggo PowerShell?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Piye cara mbalekake bagean integral saka angka desimal tartamtu nganggo PowerShell?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Piye cara mbalekake akar kuadrat angka tartamtu nganggo PowerShell?
[Math]::Sqrt(16) #Returns 4

Piye cara mbalekake konstan PI nganggo PowerShell?
[Math]::Pi #Returns 3,14159265358979

Piye cara mbalekake basis logaritma natural (konstan e) nganggo PowerShell?
[Math]::E #Returns 2,71828182845905

Piye carane ngecek yen angka iku genap utawa ganjil nganggo PowerShell?
[bool]($number%2)

Up


Hashtables

Piye carane nggawe hashtable kosong nganggo PowerShell?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Piye carane nggawe hashtable karo item nganggo PowerShell?

Piye carane nggawe hashtable miturut kunci/jeneng (ordered dictionary) karo item nganggo PowerShell?

Piye carane nambah item (pasangan key-value) nyang hashtable nganggo PowerShell?
$hashtable.Add('Key3', 'Value3')

Piye carane entuk biji tartamtu saka hashtable nganggo PowerShell?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Piye carane entuk biji minimum hashtable nganggo PowerShell?

Piye carane entuk biji maksimum hashtable nganggo PowerShell?

Piye carane ngowahi item ing hashtable nganggo PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Piye carane ngilangi item ing hashtable nganggo PowerShell?
$hashtable.Remove('Key1')

Piye carane mbusak hashtable nganggo PowerShell?
$hashtable.Clear()

Piye carane ngecek anane key/value tartamtu ing hashtable nganggo PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Piye cara ngurutake dening key/value ing hashtable nganggo PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Piye carane nggawe array kosong nganggo PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Piye carane nggawe array karo item nganggo PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Piye carane nambah item nyang array nganggo PowerShell?
$array += 'D'
[void]$array.Add('D')

Piye carane ngowahi item ing array nganggo PowerShell?
$array[0] = 'Z' # 1st item[0]

Piye carane ngecek ukuran array nganggo PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Piye carane njupuk siji/pirang-pirang/kabeh item ing array nganggo PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Piye carane ngilangi item kosong ing array nganggo PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Piye carane ngecek yen item ana ing array nganggo PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Piye cara nemokake nomer indeks item ing array nganggo PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Piye carane mbalik urutan item ing array nganggo PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Piye cara ngasilake item acak saka array nganggo PowerShell?
$array | Get-Random

Piye cara ngurutake array ing arah munggah/mudhun nganggo PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Piye carane ngitung cacahe item ing array nganggo PowerShell?
$array.Count

Piye carane nambahi array nyang liyane nganggo PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Piye cara nemokake duplikasi saka array nganggo PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Piye carane ngilangi duplikasi saka array nganggo PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Piye carane nggawe array karo item diwiwiti karo prefix (“user01″,”user02”,… “user10”) nganggo PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Piye carane ndhaftar ACL saka user AD nganggo PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Piye carane ndhaftar ACL saka folder nganggo PowerShell?
(Get-Acl -Path C:\scripts).Access

Piye carane ndhaftar entri ijin ACL tartamtu (user utawa grup) saka user AD nganggo PowerShell?

Up


Variables

Apa jenis data sing paling umum ing PowerShell?

Piye cara nemokake biji minimum lan maksimum kanggo pirang-pirang jenis variabel nganggo PowerShell?

Piye carane ngetes datatype nganggo PowerShell?

Piye carane nggawe variabel Here-String nganggo PowerShell?

Piye carane nggawe variabel nganggo PowerShell?
$powershellGuru = 'Hello'

Piye carane nggawe variabel konstan nganggo PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Piye carane nggawe variabel global nganggo PowerShell?
$Global:powershellGuru = 'Hello'

Piye carane maca variabel nganggo PowerShell?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

Piye carane ngecek jenis variabel nganggo PowerShell?
$powershellGuru.GetType()

Piye cara nemokake variabel in lingkup global nganggo PowerShell?
Get-Variable -Scope Global

Piye carane entuk variabel tartamtu miturut jeneng nganggo PowerShell?
Get-Variable -Include *Preference -Exclude W*

Piye cara nemtokake jenis data tartamtu kanggo variabel nganggo PowerShell?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

Piye carane nginisialisasi pirang-pirang variabel sing bijine padha nganggo PowerShell?
$a = $b = $c = $d = $e = 0

Apa alias kanggo variabel “$_” nganggo PowerShell?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

Piye carane ngilangi variabel sing jenenge diwiwiti karo “count” nganggo PowerShell?
Remove-Variable -Name count*

Piye carane entuk variabel lokal environment nganggo PowerShell?
Get-ChildItem -Path Env:

Piye carane entuk Path Environmental Variable baris demi baris nganggo PowerShell?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

Piye carane nambah path anyar (conto C:\SysinternalsSuite) nyang Path Environmental Variable nganggo PowerShell?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

Piye cara nggabungake variabel nganggo PowerShell?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

Piye cara nggunakake ErrorVariable nganggo PowerShell?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

Piye cara ngaktifake/mateni ekuivalen saka “Option Explicit” (VBScript: ngwajibake variabel dinyatakake) nganggo PowerShell?

Up


Static .NET Methods

Piye carane entuk anggota statis nganggo PowerShell?
[DateTime] | Get-Member -Static

Up


Sounds

Piye carane muter swara “beep” nganggo PowerShell?
[System.Console]::Beep()

Piye carane muter swara “asterisk” nganggo PowerShell?
[System.Media.SystemSounds]::Asterisk.Play()

Piye carane muter swara “exclamation” nganggo PowerShell?
[System.Media.SystemSounds]::Exclamation.Play()

Piye carane entuk swara sing kasedhiya nganggo PowerShell?
[System.Media.SystemSounds] | Get-Member -Static

Piye carane muter swara “WAV” nganggo PowerShell?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
utawa
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

Piye cara ngaktifake pidato teks tertulis nganggo PowerShell?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

Piye carane maca file XML nganggo PowerShell?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

Piye carane ngekspor data dadi file XML nganggo PowerShell?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

Piye carane ngimpor data saka file CLIXML nganggo PowerShell?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

Piye carane nggawe GUI dhasar (Windows Form) nganggo PowerShell?

Up


Characters

Piye carane ngganti nilai ASCII dadi karakter nganggo PowerShell?
[char]64

Piye carane ngganti karakter dadi nilai ASCII nganggo PowerShell?
[int][char]'@'

Piye cara ngasilake aksara Inggris nganggo PowerShell?
[char[]](97..122)

Up


Compare

Piye cara mbandhingake rong array nganggo PowerShell?

Piye cara mbandhingake rong proses nganggo PowerShell?

Up


Microsoft Exchange

Piye carane njupuk dhaftar piranti seluler sing disinkronake karo kotak pesen user nganggo PowerShell?
Get-ActiveSyncDeviceStatistics

Piye carane nambah ijin “Full Access” nyang kotak pesen kanggo user nganggo PowerShell?
Add-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess'

Piye carane ngilangi ijin “Full Access” nyang kotak pesen kanggo user nganggo PowerShell?
Remove-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess' -InheritanceType 'All'

Piye carane nambah ijin “Send As” nyang kotak pesen kanggo user nganggo PowerShell?
Add-ADPermission -Identity $dn -User 'DOMAIN\powershellguru' -ExtendedRights 'Send-As'

Piye carane ngilangi ijin “Send As” nyang kotak pesen kanggo user nganggo PowerShell?

Piye cara nemokake aturan inbox saka kotak pesen nganggo PowerShell?
Get-InboxRule -Mailbox 'Powershell.Guru'

Piye carane entuk alamat SMTP kanggo user sing duwe OWA (Outlook Web Access) sing aktif nganggo PowerShell?
Get-CASMailbox -Filter{OWAEnabled -eq $true} | Select-Object -Property Name, PrimarySMTPAddress

Exchange 2007

Piye carane nginstal prasyarat kanggo server Exchange Server 2007 Hub Transport, Mailbox (MBX), and Client Access Server (CAS) nganggo PowerShell?