InfraLab
POWERSHELL46 cmd

PowerShell チート集

Windows インフラ運用で使う PowerShell のヘルプ、オブジェクトパイプ、サービス、プロセス、イベントログ、ネットワーク、Active Directory、WinRM、スクリプト基礎を整理したチート集。

更新日
2026-05-29
参照範囲
公式ドキュメント / man page / 主要ベンダーCLI
対象実装
主要 Linux / BSD / ネットワーク機器 CLI の一般的な実装
免責
OS とバージョン差分は実環境で確認してください。

このチートシートの使いどころ

PowerShell チート集は、Windows インフラ運用で使う PowerShell のヘルプ、オブジェクトパイプ、サービス、プロセス、イベントログ、ネットワーク、Active Directory、WinRM、スクリプト基礎を整理したチート集。 対象は公式ドキュメント、man page、主要ベンダー CLI で確認できる現行の一般的な実装です。カテゴリは基本、オブジェクト・パイプ、ファイル・レジストリ、ネットワーク、Active Directoryを中心に、46件のコマンドや値を用途別に引けます。障害調査、設定変更前の確認、作業メモ作成で、PowerShell、Windows、Active Directory、AD、WinRMに関連する操作を短時間で探すために使います。

46 / 46

Get-Command

PowerShell で Get-Command を実務運用で使う

Example
PS> Get-Command *Service*
Get-Help

PowerShell で Get-Help を実務運用で使う

Example
PS> Get-Help Get-Process -Examples
Get-Member

PowerShell で Get-Member を実務運用で使う

Example
PS> Get-Process | Get-Member
Out-GridView

PowerShell で Out-GridView を実務運用で使う

Example
PS> Get-Service | Out-GridView
Get-Module

PowerShell で Get-Module を実務運用で使う

Example
PS> Get-Module -ListAvailable
Import-Module

PowerShell で Import-Module を実務運用で使う

Example
PS> Import-Module ActiveDirectory
Update-Help

PowerShell で Update-Help を実務運用で使う

Example
PS> Update-Help -Force
Select-Object

PowerShell で Select-Object を実務運用で使う

Example
PS> Get-Process | Select-Object Name,Id,CPU
Where-Object

PowerShell で Where-Object を実務運用で使う

Example
PS> Get-Service | Where-Object Status -eq Running
ForEach-Object

PowerShell で ForEach-Object を実務運用で使う

Example
PS> Get-Process | ForEach-Object { $_.Name }
Sort-Object

PowerShell で Sort-Object を実務運用で使う

Example
PS> Get-Process | Sort-Object CPU -Descending
Group-Object

PowerShell で Group-Object を実務運用で使う

Example
PS> Get-Process | Group-Object ProcessName
Measure-Object

PowerShell で Measure-Object を実務運用で使う

Example
PS> Get-ChildItem C:\Logs | Measure-Object Length -Sum
Export-Csv

PowerShell で Export-Csv を実務運用で使う

Example
PS> Get-Service | Export-Csv .\services.csv -NoTypeInformation
ConvertTo-Json

PowerShell で ConvertTo-Json を実務運用で使う

Example
PS> Get-Process | Select-Object -First 3 | ConvertTo-Json
Get-ChildItem

PowerShell で Get-ChildItem を実務運用で使う

Example
PS> Get-ChildItem C:\Windows\System32 -Filter *.dll
Get-Content

PowerShell で Get-Content を実務運用で使う

Example
PS> Get-Content C:\Logs\app.log -Tail 100 -Wait
Set-Content

PowerShell で Set-Content を実務運用で使う

Example
PS> Set-Content .\note.txt "hello"
Copy-Item

PowerShell で Copy-Item を実務運用で使う

Example
PS> Copy-Item .\app.conf \server01\c$\Temp\
Remove-Item

PowerShell で Remove-Item を実務運用で使う

Example
PS> Remove-Item .\old.log -Force
Get-ItemProperty

PowerShell で Get-ItemProperty を実務運用で使う

Example
PS> Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion
New-ItemProperty

PowerShell で New-ItemProperty を実務運用で使う

Example
PS> New-ItemProperty HKLM:\Software\Acme -Name Enabled -Value 1 -PropertyType DWord
Get-Service

PowerShell で Get-Service を実務運用で使う

Example
PS> Get-Service | Where-Object Status -eq Stopped
Restart-Service

PowerShell で Restart-Service を実務運用で使う

Example
PS> Restart-Service Spooler
Get-Process

PowerShell で Get-Process を実務運用で使う

Example
PS> Get-Process -Name w3wp
Stop-Process

PowerShell で Stop-Process を実務運用で使う

Example
PS> Stop-Process -Id 1234 -Force
Get-WinEvent

PowerShell で Get-WinEvent を実務運用で使う

Example
PS> Get-WinEvent -LogName System -MaxEvents 20
Get-EventLog

Windows PowerShell 5.1 のイベントログ取得コマンド。PowerShell 7+ では削除済みのため、現行環境では Get-WinEvent を使う。

Example
PS> Get-WinEvent -LogName Application -MaxEvents 50
Test-NetConnection

PowerShell で Test-NetConnection を実務運用で使う

Example
PS> Test-NetConnection example.com -Port 443
Resolve-DnsName

PowerShell で Resolve-DnsName を実務運用で使う

Example
PS> Resolve-DnsName example.com -Type MX
Get-NetTCPConnection

PowerShell で Get-NetTCPConnection を実務運用で使う

Example
PS> Get-NetTCPConnection -State Listen
Get-NetAdapter

PowerShell で Get-NetAdapter を実務運用で使う

Example
PS> Get-NetAdapter | Format-Table Name,Status,LinkSpeed
Get-NetIPConfiguration

PowerShell で Get-NetIPConfiguration を実務運用で使う

Example
PS> Get-NetIPConfiguration
Get-DnsClientServerAddress

PowerShell で Get-DnsClientServerAddress を実務運用で使う

Example
PS> Get-DnsClientServerAddress -AddressFamily IPv4
Get-ADUser

PowerShell で Get-ADUser を実務運用で使う

Example
PS> Get-ADUser -Filter * -Properties mail | Select-Object Name,mail
Get-ADComputer

PowerShell で Get-ADComputer を実務運用で使う

Example
PS> Get-ADComputer -Filter * -Properties OperatingSystem
Get-ADGroupMember

PowerShell で Get-ADGroupMember を実務運用で使う

Example
PS> Get-ADGroupMember "Domain Admins"
Search-ADAccount

PowerShell で Search-ADAccount を実務運用で使う

Example
PS> Search-ADAccount -LockedOut
Enter-PSSession

PowerShell で Enter-PSSession を実務運用で使う

Example
PS> Enter-PSSession -ComputerName server01
Invoke-Command

PowerShell で Invoke-Command を実務運用で使う

Example
PS> Invoke-Command -ComputerName server01 -ScriptBlock { Get-Service }
New-PSSession

PowerShell で New-PSSession を実務運用で使う

Example
PS> $s = New-PSSession -ComputerName server01
Copy-Item -ToSession

PowerShell で Copy-Item -ToSession を実務運用で使う

Example
PS> Copy-Item .\tool.ps1 C:\Temp -ToSession $s
param

PowerShell で param を実務運用で使う

Example
PS> param([string]$Path = "C:\Logs")
function

PowerShell で function を実務運用で使う

Example
PS> function Restart-App { param($Name) Restart-Service $Name }
try catch

PowerShell で try catch を実務運用で使う

Example
PS> try { Restart-Service App } catch { Write-Error $_ }
CmdletBinding

PowerShell で CmdletBinding を実務運用で使う

Example
PS> [CmdletBinding()] param([Parameter(Mandatory)] [string]$Name)
Related