PowerShellコマンドレットのエイリアス一覧(バージョン5.1と7.3.6で確認)
概要
PowerShellのコマンドレットは、「 Get-
や Set-
、Remove-
、 New-
」などの文字から始まるコマンド(たとえばプロセスを確認するコマンドは Get-Process
)があります。
一方、UnixやLinuxのコマンド(UnixやLinuxのプロセス確認コマンドはps
)と比較すると、PowerShellのコマンドレットは長い文字列で構成されたコマンドと言えるでしょう。
CLIでコマンドレットを入力すると1回いっかい長い文字列のコマンドを打つ必要がある為、時間がかかり面倒。
そんなケースの時、短い文字列のコマンド、エイリアス(別名)を活用する事で時短につながります。
今回は以前から気になっていたPowerShellコマンドレットのエイリアスを調べ表形式で紹介。
なお、確認するPowerShellのバージョンはWindows標準で導入されているバージョン5.1
と2023年8月現在、最新バージョンである7.3.6
が対象です。
この記事のターゲット
- PowerShellユーザーの方
- 下記の環境下におけるPowerShellコマンドレットのエイリアスを把握したい方
- Windows標準のPowerShell:
5.1
- 2023年8月現在、最新のPowerShell:
7.3.6
- Windows標準のPowerShell:
環境
PowerShell 5.1(環境)
PS C:\WINDOWS\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.3031
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3031
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\WINDOWS\system32>
PowerShell 7.3.6(環境)
PS D:\Downloads\PowerShell-7.3.6-win-x64> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS D:\Downloads\PowerShell-7.3.6-win-x64>
エイリアス一覧
コマンド結果の生データ(省略あり)
表形式に変換したコマンド結果を後述するので、ここでの生データ(Raw data)は先頭付近のみ記載し、それ以降の結果は省略しています。
Get-Alias
PowerShell 5.1(Get-Aliasコマンドレット)
PS C:\WINDOWS\system32> Get-Alias
CommandType Name Version Source
----------- ---- ------- ------
Alias % -> ForEach-Object
Alias ? -> Where-Object
Alias ac -> Add-Content
Alias asnp -> Add-PSSnapin
Alias cat -> Get-Content
Alias cd -> Set-Location
~~~ 以降は省略(後述で表形式を紹介するため) ~~~
PS C:\WINDOWS\system32>
PowerShell 7.3.6(Get-Aliasコマンドレット)
PS D:\Downloads\PowerShell-7.3.6-win-x64> Get-Alias
CommandType Name Version Source
----------- ---- ------- ------
Alias ? -> Where-Object
Alias % -> ForEach-Object
Alias ac -> Add-Content
Alias cat -> Get-Content
Alias cd -> Set-Location
~~~ 以降は省略(後述で表形式を紹介するため) ~~~
PS D:\Downloads\PowerShell-7.3.6-win-x64>
表に変換したコマンド結果
必要な項目だけ抜粋しPowerShellコマンドレット(Definition)で昇順ソートした表。
PowerShell 5.1(表に変換)
表に変換したコマンド結果 - PowerShell 5.1 < クリックで折りたたみが開く >
参考情報:すべての項目を表示(一部省略) < クリックで折りたたみが開く >
HelpUri | ResolvedCommandName | DisplayName | ReferencedCommand | ResolvedCommand | Definition | Options | Description | OutputType | Name | CommandType | Source | Version | Visibility | ModuleName | Module | RemotingCapability | Parameters | ParameterSets |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://go.microsoft.com/fwlink/?LinkID=113300 | ForEach-Object | % -> ForEach-Object | ForEach-Object | ForEach-Object | ForEach-Object | ReadOnly, AllScope | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | % | Alias | Public | None | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||||||
https://go.microsoft.com/fwlink/?LinkID=113423 | Where-Object | ? -> Where-Object | Where-Object | Where-Object | Where-Object | ReadOnly, AllScope | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | ? | Alias | Public | None | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||||||
ac -> Add-Content | Add-Content | ReadOnly, AllScope | ac | Alias | Public | PowerShell | ||||||||||||
https://go.microsoft.com/fwlink/?LinkID=113281 | Add-PSSnapin | asnp -> Add-PSSnapin | Add-PSSnapin | Add-PSSnapin | Add-PSSnapIn | ReadOnly, AllScope | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | asnp | Alias | Public | PowerShell | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||||||
cat -> Get-Content | Get-Content | AllScope | cat | Alias | Public | PowerShell | ||||||||||||
cd -> Set-Location | Set-Location | AllScope | cd | Alias | Public | PowerShell | ||||||||||||
https://go.microsoft.com/fwlink/?LinkID=507579 | ConvertFrom-String | CFS -> ConvertFrom-String | ConvertFrom-String | ConvertFrom-String | ConvertFrom-String | None | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | CFS | Alias | Microsoft.PowerShell.Utility | 3.1.0.0 | Public | Microsoft.PowerShell.Utility | Microsoft.PowerShell.Utility | PowerShell | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||
~~~ 以降は省略 ~~~ |
PowerShell 7.3.6(表に変換)
表に変換したコマンド結果 - PowerShell 7.3.6 < クリックで折りたたみが開く >
参考情報:すべての項目を表示(一部省略) < クリックで折りたたみが開く >
HelpUri | ResolvedCommandName | DisplayName | ReferencedCommand | ResolvedCommand | Definition | Options | Description | OutputType | Name | CommandType | Source | Version | Visibility | ModuleName | Module | RemotingCapability | Parameters | ParameterSets |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://go.microsoft.com/fwlink/?LinkID=2096806 | Where-Object | ? -> Where-Object | Where-Object | Where-Object | Where-Object | ReadOnly, AllScope | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | ? | Alias | Public | None | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||||||
https://go.microsoft.com/fwlink/?LinkID=2096867 | ForEach-Object | % -> ForEach-Object | ForEach-Object | ForEach-Object | ForEach-Object | ReadOnly, AllScope | System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSTypeName] | % | Alias | Public | None | System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata] | ||||||
ac -> Add-Content | Add-Content | ReadOnly | ac | Alias | Public | PowerShell | ||||||||||||
cat -> Get-Content | Get-Content | None | cat | Alias | Public | PowerShell | ||||||||||||
cd -> Set-Location | Set-Location | AllScope | cd | Alias | Public | PowerShell | ||||||||||||
~~~ 以降は省略 ~~~ |
自分用のメモ:コマンド結果をMarkdownの表に変換した方法
コマンド結果をMarkdownの表に変換した方法 < クリックで折りたたみが開く >
- PowerShellコマンド結果をCSVファイルに出力
- PowerShell 5.1で実行したコマンド
Get-Alias | Export-Csv -NoTypeInformation D:\Downloads\PS5.1_alias.csv -Encoding UTF8
- PowerShell 7.3.6で実行したコマンド
Get-Alias | Export-Csv D:\Downloads\PS7.3_alias.csv -Encoding UTF8
- PowerShell 5.1で実行したコマンド
- CSVファイルからExcelファイルに変換
カンマ(,
)区切りからタブ(\t
)区切りにする為、Excelファイルに変換する。
https://command-lab.com/tech/csv-excel/ - Excelファイルの表をコピーしテキストエディターに貼り付け
Excel内にあるコマンド結果の表がタブ区切りのテキスト形式となる。
* 私は正規表現が可能なテキストエディターとしてVS Codeを使用しました。 - テキストエディターの正規表現を使いMarkdown形式に変換
- Ctrl + H で置換機能を起動
- 置換機能のオプションで
正規表現を使用する
をON - 下記条件で置換
- 検索条件
^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$
- 置換文字
| $1 | $2 | $3 | $4 | $5 | $6 | $7 | $8 | $9 | $10 | $11 | $12 | $13 | $14 | $15 | $16 | $17 | $18 | $19 |
- 検索条件
- Markdownのテーブル形式のテキストデータが完成
PowerShell 5.1 と 7.3.6 の差異を比較
差異があるコマンドレットだけをピックアップしました。
差異の内容 | PowerShellコマンドレット | エイリアス名 |
---|---|---|
5.1のみ | Add-PSSnapIn | asnp |
5.1のみ | ConvertFrom-String | CFS |
5.1のみ | Export-PSSession | epsn |
7.3のみ | Get-Error | gerr |
5.1のみ | Get-PSSnapIn | gsnp |
5.1のみ | Get-WmiObject | gwmi |
5.1のみ | Import-PSSession | ipsn |
5.1のみ | Invoke-WebRequest | curl |
5.1のみ | Invoke-WebRequest | wget |
5.1のみ | New-PSSessionConfigurationFile | npssc |
5.1のみ | Out-Printer | lp |
5.1のみ | powershell_ise.exe | ise |
5.1のみ | Remove-PSSnapin | rsnp |
5.1のみ | Remove-WMIObject | rwmi |
5.1のみ | Resume-Job | rujb |
5.1のみ | Set-Content | sc |
5.1のみ | Set-WMIInstance | swmi |
5.1のみ | Suspend-Job | sujb |
5.1のみ | Trace-Command | trcm |
PowerShellバージョン毎のエイリアス対応 < クリックで折りたたみが開く >
5.1 | 7.3 | PowerShellコマンドレット | エイリアス名 |
---|---|---|---|
☑ | ☑ | Add-Content | ac |
☑ | ☐ | Add-PSSnapIn | asnp |
☑ | ☑ | Clear-Content | clc |
☑ | ☑ | Clear-History | clhy |
☑ | ☑ | Clear-Host | clear |
☑ | ☑ | Clear-Host | cls |
☑ | ☑ | Clear-Item | cli |
☑ | ☑ | Clear-ItemProperty | clp |
☑ | ☑ | Clear-Variable | clv |
☑ | ☑ | Compare-Object | compare |
☑ | ☑ | Compare-Object | diff |
☑ | ☑ | Connect-PSSession | cnsn |
☑ | ☐ | ConvertFrom-String | CFS |
☑ | ☑ | Convert-Path | cvpa |
☑ | ☑ | Copy-Item | copy |
☑ | ☑ | Copy-Item | cp |
☑ | ☑ | Copy-Item | cpi |
☑ | ☑ | Copy-ItemProperty | cpp |
☑ | ☑ | Disable-PSBreakpoint | dbp |
☑ | ☑ | Disconnect-PSSession | dnsn |
☑ | ☑ | Enable-PSBreakpoint | ebp |
☑ | ☑ | Enter-PSSession | etsn |
☑ | ☑ | Exit-PSSession | exsn |
☑ | ☑ | Export-Alias | epal |
☑ | ☑ | Export-Csv | epcsv |
☑ | ☐ | Export-PSSession | epsn |
☑ | ☑ | ForEach-Object | % |
☑ | ☑ | ForEach-Object | foreach |
☑ | ☑ | Format-Custom | fc |
☑ | ☑ | Format-Hex | fhx |
☑ | ☑ | Format-List | fl |
☑ | ☑ | Format-Table | ft |
☑ | ☑ | Format-Wide | fw |
☑ | ☑ | Get-Alias | gal |
☑ | ☑ | Get-ChildItem | dir |
☑ | ☑ | Get-ChildItem | gci |
☑ | ☑ | Get-ChildItem | ls |
☑ | ☑ | Get-Command | gcm |
☑ | ☑ | Get-Content | cat |
☑ | ☑ | Get-Content | gc |
☑ | ☑ | Get-Content | type |
☐ | ☑ | Get-Error | gerr |
☑ | ☑ | Get-History | ghy |
☑ | ☑ | Get-History | h |
☑ | ☑ | Get-History | history |
☑ | ☑ | Get-Item | gi |
☑ | ☑ | Get-ItemProperty | gp |
☑ | ☑ | Get-ItemPropertyValue | gpv |
☑ | ☑ | Get-Job | gjb |
☑ | ☑ | Get-Location | gl |
☑ | ☑ | Get-Location | pwd |
☑ | ☑ | Get-Member | gm |
☑ | ☑ | Get-Module | gmo |
☑ | ☑ | Get-Process | gps |
☑ | ☑ | Get-Process | ps |
☑ | ☑ | Get-PSBreakpoint | gbp |
☑ | ☑ | Get-PSCallStack | gcs |
☑ | ☑ | Get-PSDrive | gdr |
☑ | ☑ | Get-PSSession | gsn |
☑ | ☐ | Get-PSSnapIn | gsnp |
☑ | ☑ | Get-Service | gsv |
☑ | ☑ | Get-Unique | gu |
☑ | ☑ | Get-Variable | gv |
☑ | ☐ | Get-WmiObject | gwmi |
☑ | ☑ | Group-Object | group |
☑ | ☑ | help | man |
☑ | ☑ | Import-Alias | ipal |
☑ | ☑ | Import-Csv | ipcsv |
☑ | ☑ | Import-Module | ipmo |
☑ | ☐ | Import-PSSession | ipsn |
☑ | ☑ | Invoke-Command | icm |
☑ | ☑ | Invoke-Expression | iex |
☑ | ☑ | Invoke-History | ihy |
☑ | ☑ | Invoke-History | r |
☑ | ☑ | Invoke-Item | ii |
☑ | ☑ | Invoke-RestMethod | irm |
☑ | ☐ | Invoke-WebRequest | curl |
☑ | ☑ | Invoke-WebRequest | iwr |
☑ | ☐ | Invoke-WebRequest | wget |
☑ | ☑ | Invoke-WMIMethod | iwmi |
☑ | ☑ | Measure-Object | measure |
☑ | ☑ | mkdir | md |
☑ | ☑ | Move-Item | mi |
☑ | ☑ | Move-Item | move |
☑ | ☑ | Move-Item | mv |
☑ | ☑ | Move-ItemProperty | mp |
☑ | ☑ | New-Alias | nal |
☑ | ☑ | New-Item | ni |
☑ | ☑ | New-Module | nmo |
☑ | ☑ | New-PSDrive | mount |
☑ | ☑ | New-PSDrive | ndr |
☑ | ☑ | New-PSSession | nsn |
☑ | ☐ | New-PSSessionConfigurationFile | npssc |
☑ | ☑ | New-Variable | nv |
☑ | ☑ | Out-GridView | ogv |
☑ | ☑ | Out-Host | oh |
☑ | ☐ | Out-Printer | lp |
☑ | ☑ | Pop-Location | popd |
☑ | ☐ | powershell_ise.exe | ise |
☑ | ☑ | Push-Location | pushd |
☑ | ☑ | Receive-Job | rcjb |
☑ | ☑ | Receive-PSSession | rcsn |
☑ | ☑ | Remove-Item | del |
☑ | ☑ | Remove-Item | erase |
☑ | ☑ | Remove-Item | rd |
☑ | ☑ | Remove-Item | ri |
☑ | ☑ | Remove-Item | rm |
☑ | ☑ | Remove-Item | rmdir |
☑ | ☑ | Remove-ItemProperty | rp |
☑ | ☑ | Remove-Job | rjb |
☑ | ☑ | Remove-Module | rmo |
☑ | ☑ | Remove-PSBreakpoint | rbp |
☑ | ☑ | Remove-PSDrive | rdr |
☑ | ☑ | Remove-PSSession | rsn |
☑ | ☐ | Remove-PSSnapin | rsnp |
☑ | ☑ | Remove-Variable | rv |
☑ | ☐ | Remove-WMIObject | rwmi |
☑ | ☑ | Rename-Item | ren |
☑ | ☑ | Rename-Item | rni |
☑ | ☑ | Rename-ItemProperty | rnp |
☑ | ☑ | Resolve-Path | rvpa |
☑ | ☐ | Resume-Job | rujb |
☑ | ☑ | Select-Object | select |
☑ | ☑ | Select-String | sls |
☑ | ☑ | Set-Alias | sal |
☑ | ☐ | Set-Content | sc |
☑ | ☑ | Set-Item | si |
☑ | ☑ | Set-ItemProperty | sp |
☑ | ☑ | Set-Location | cd |
☑ | ☑ | Set-Location | chdir |
☑ | ☑ | Set-Location | sl |
☑ | ☑ | Set-PSBreakpoint | sbp |
☑ | ☑ | Set-Variable | set |
☑ | ☑ | Set-Variable | sv |
☑ | ☐ | Set-WMIInstance | swmi |
☑ | ☑ | Show-Command | shcm |
☑ | ☑ | Sort-Object | sort |
☑ | ☑ | Start-Job | sajb |
☑ | ☑ | Start-Process | saps |
☑ | ☑ | Start-Process | start |
☑ | ☑ | Start-Service | sasv |
☑ | ☑ | Start-Sleep | sleep |
☑ | ☑ | Stop-Job | spjb |
☑ | ☑ | Stop-Process | kill |
☑ | ☑ | Stop-Process | spps |
☑ | ☑ | Stop-Service | spsv |
☑ | ☐ | Suspend-Job | sujb |
☑ | ☑ | Tee-Object | tee |
☑ | ☐ | Trace-Command | trcm |
☑ | ☑ | Wait-Job | wjb |
☑ | ☑ | Where-Object | ? |
☑ | ☑ | Where-Object | where |
☑ | ☑ | Write-Output | echo |
☑ | ☑ | Write-Output | write |
公式リファレンス「Get-Aliasコマンド」
まとめ
エイリアスを取得できるPowerShellのコマンドレット「Get-Alias」の結果を、
5.1 と v7.3.6 の2つのバージョンで確認しました。
PowerShellのエイリアスを使う用途としては、CLIでコマンドレットを打つときに時短となり便利そうですね。
エイリアスの内容を、ざっと見る限りUNIXのコマンドを流用しているようなので、
UNIXやLinuxのコマンドをご存じの方は、作業効率が上がりそうです。
ただ、エイリアスはコマンドのみでオプションに関してはPowerShellコマンドレットの物を使用する必要がありますので、ご注意ください。
また、PowerShellスクリプトを作成する際、エイリアスを使ってしまうとPowerShellのコマンドレットなのか、
OSのコマンド(Windows OSであればコマンドプロンプト)なのかが不明確になってしまいます。
PowerShellスクリプト作成時は、省略していないフルのコマンドレットでコードを書いた方が可読性が良さそうです。
関連記事
Discussion