PowerShell চিট শিট
অনুসন্ধানযোগ্য, প্রিন্টযোগ্য PowerShell রেফারেন্স — cmdlets, পাইপলাইন, ভেরিয়েবল, ফাইল, লুপ, ফাংশন, অবজেক্ট এবং প্রশাসন। বিনামূল্যে।
Getting help & discovery
12Get-Help Get-Process
Get-Help Get-Process -Examples
Get-Help Get-Process -Full
Get-Help about_Functions
Update-Help
Get-Command -Noun Process
Get-Command -Verb Get
Get-Command *service*
Get-Process | Get-Member
Get-Alias ls
Get-Alias -Definition Get-ChildItem
$PSVersionTable
Variables & types
13$x = 5
[int]$n = '42'
$null
$true; $false
$arr = @(1, 2, 3)
$arr += 4
$arr[0]; $arr[-1]
$hash = @{ Name = 'Ann'; Age = 30 }
$hash['Name']; $hash.Name
$env:PATH
$env:MY_VAR = 'value'
Get-Variable
[math]::Round(3.14159, 2)
Pipeline & filtering
12Get-Process | Where-Object { $_.CPU -gt 10 }
Get-Process | ? CPU -gt 10
Get-Process | ForEach-Object { $_.Name }
Get-Process | % { $_.Kill() }
Get-Process | Select-Object Name, Id
Get-Process | Select-Object -First 5
Get-Process | Sort-Object CPU -Descending
Get-Process | Group-Object Company
Get-Process | Measure-Object CPU -Sum
Get-ChildItem | Select-Object -Unique
1..5 | ForEach-Object { $_ * 2 }
Get-Process | Out-GridView
Files & paths
13Get-ChildItem -Path C:\Logs
Get-ChildItem -Recurse -Filter *.log
Get-Content .\file.txt
Get-Content .\file.txt -Tail 20
Set-Content .\file.txt -Value 'Hi'
Add-Content .\file.txt -Value 'Hi'
Copy-Item a.txt b.txt
Move-Item a.txt .\dir\
Remove-Item a.txt -Force
New-Item -ItemType Directory -Path .\dir
Test-Path .\file.txt
Get-Location
Set-Location C:\Temp
Strings & text
12'Hello World' -match 'World'
'Hello' -replace 'l', 'L'
'a,b,c' -split ','
'a-b-c'.Split('-')
'a', 'b' -join ', '
Select-String -Path *.log -Pattern 'error'
'{0} of {1}' -f 3, 10
' hi '.Trim()
'Hello'.ToUpper()
'Hello'.Substring(0, 3)
'Hello'.Contains('ell')
'Hello'.Length
Loops & conditionals
12if ($x -gt 0) { 'pos' } elseif ($x -eq 0) { 'zero' } else { 'neg' }
switch ($x) { 1 { 'one' } default { 'other' } }
foreach ($i in $arr) { $i }
for ($i = 0; $i -lt 5; $i++) { $i }
while ($x -lt 10) { $x++ }
do { $x++ } while ($x -lt 10)
$x -eq 5; $x -ne 5
$x -gt 5; $x -lt 5
$x -ge 5; $x -le 5
'abc' -like 'a*'
@(1, 2, 3) -contains 2
break; continue
Functions & scripts
12function Get-Sum { param($a, $b) $a + $b }
Get-Sum -a 2 -b 3
function Test { param([int]$n = 1) }
param([Parameter(Mandatory)]$Name)
return $value
function F { [CmdletBinding()] param() }
Write-Verbose 'msg' -Verbose
Write-Output $result
Write-Error 'failed'
.\script.ps1 -Arg value
. .\functions.ps1
try { } catch { $_ } finally { }
Objects & properties
12Get-Process | Select-Object -ExpandProperty Name
(Get-Process).Name
Get-Process | Select-Object Name, @{ Name = 'MB'; Expression = { $_.WS / 1MB } }
[PSCustomObject]@{ Name = 'Ann'; Age = 30 }
$obj | Add-Member -NotePropertyName Tag -NotePropertyValue 'x'
$obj.PSObject.Properties.Name
$obj | Format-Table -AutoSize
$obj | Format-List *
$obj | ConvertTo-Json -Depth 5
Get-Content data.json | ConvertFrom-Json
$obj | Export-Csv out.csv -NoTypeInformation
Import-Csv data.csv
Processes & services
12Get-Process
Get-Process -Name chrome
Stop-Process -Name notepad -Force
Start-Process notepad.exe
Get-Service
Get-Service -Name wuauserv
Start-Service -Name wuauserv
Stop-Service -Name wuauserv
Restart-Service -Name wuauserv
Set-Service -Name wuauserv -StartupType Manual
Get-EventLog -LogName System -Newest 20
Get-WinEvent -LogName Application -MaxEvents 20
Remoting & jobs
12Enter-PSSession -ComputerName Srv01
Exit-PSSession
Invoke-Command -ComputerName Srv01 -ScriptBlock { Get-Service }
$s = New-PSSession -ComputerName Srv01
Invoke-Command -Session $s -ScriptBlock { hostname }
Remove-PSSession $s
Start-Job -ScriptBlock { Get-Process }
Get-Job
Receive-Job -Id 1 -Keep
Wait-Job -Id 1
Stop-Job -Id 1; Remove-Job -Id 1
Get-Process | Start-ThreadJob { $input }
Modules & packages
12Get-Module
Get-Module -ListAvailable
Import-Module Pester
Remove-Module Pester
Find-Module -Name PSReadLine
Install-Module PSReadLine -Scope CurrentUser
Update-Module PSReadLine
Uninstall-Module PSReadLine
Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-PSRepository
$PROFILE
“:q”-এর সাথে কোনো এন্ট্রি মেলে না।
PowerShell চিট শিট সম্পর্কে
এই PowerShell চিট শিটটি শেলটিকে আবিষ্কার থেকে অটোমেশন পর্যন্ত কভার করে: সাহায্য পাওয়া ও আবিষ্কার, ভেরিয়েবল ও টাইপ, পাইপলাইন ও ফিল্টারিং, ফাইল ও পাথ, স্ট্রিং ও টেক্সট, লুপ ও কন্ডিশনাল, ফাংশন ও স্ক্রিপ্ট, অবজেক্ট ও প্রপার্টি, প্রসেস ও সার্ভিস, রিমোটিং ও জব, এবং মডিউল ও প্যাকেজ।
PowerShell POSIX শেল থেকে ভিন্ন কারণ এর পাইপলাইন টেক্সট নয়, অবজেক্ট বহন করে — তাই শিটটি সেই ডিসকভারি cmdlet এবং অবজেক্ট-ফিল্টারিং প্যাটার্নের উপর নির্ভর করে যা এই মডেলকে বোধগম্য করে তোলে, পাশাপাশি অ্যাডমিনরা প্রতিদিন যেসব ফাইল, স্ট্রিং ও প্রসেস কমান্ড ব্যবহার করেন সেগুলোও।
শিটটি ফ্রি এবং ক্লায়েন্ট-সাইড। সার্চ বক্স দিয়ে cmdlet লাইভ ফিল্টার করুন, স্টিকি টেবিল অফ কনটেন্টস থেকে সেকশনগুলোর মধ্যে জাম্প করুন, এক ক্লিকে যেকোনো কমান্ড কপি করুন এবং কনসোল-পাশে রেফারেন্সের জন্য পেজটি প্রিন্ট করুন।
PowerShell চিট শিট কীভাবে ব্যবহার করবেন
- Getting help & discovery দিয়ে শুরু করুন — সেখানকার cmdlet গুলো আপনাকে বাকি সবকিছু আবিষ্কার করতে দেয়।
- শিটটি লাইভ ফিল্টার করতে Get-, service বা foreach-এর মতো একটি ভার্ব বা নাউন সার্চ করুন।
- স্টিকি সাইডবারের মাধ্যমে Pipeline & filtering বা Remoting & jobs-এর মতো একটি সেকশনে জাম্প করুন।
- আপনার PowerShell সেশনে কপি করতে একটি কমান্ড বা তার কপি আইকনে ক্লিক করুন।
- অফলাইন cmdlet রেফারেন্সের জন্য শিটটি প্রিন্ট করুন।