PowerShell、コマンドプロンプト、Linuxコマンド対応表 †
PowerShellに対応するコマンドプロンプト(DOS)コマンド, Linuxコマンドの一覧表を記します。
良く使用すると思われるコマンドレットの一覧になります。
コマンドレット対応表 †
No | セクション | PowerShell | コマンドプロンプト | Linux |
1 | ファイル・ディレクトリ関連 | Get-ChildItem | dir | ls, dir |
2 | | Get-ChildItem -Name | dir /b | ls -1 |
3 | | Get-ChildItem | Where-Object {$_.Attribute -eq "Directory"} Get-ChildItem | Where-Object { $_.PSIsContainer } | dir /ad | ls -F | grep / |
4 | | Get-ChildItem | Sort-Object LastWriteTime | dir /od | ls -ltr |
5 | | Get-ChildItem | Sort-Object LastWriteTime -Descending | dir /o-d | ls -lt |
6 | | Get-Content | type | cat |
7 | | Copy-Item | copy | cp |
8 | | Copy-Item -Recurse | xcopy robocopy | cp -r |
9 | | Remove-Item | del erase | rm |
10 | | Move-Item | move | mv |
11 | | Rename-Item | ren | mv |
12 | | Get-ChildItem -Recurse -Name | dir /b /s | find . |
13 | | (Get-Content 対象ファイル名 | Measure-Object).Count | find /c /v "" | wc -l |
14 | | Get-Location | cd chdir | pwd |
15 | | New-Item -ItemType Directory | mk mkdir | mkdir |
16 | | Set-Location | cd chdir | cd |
17 | | Remove-Item | rd rmdir | rmdir |
18 | | Compare-Object (Get-Content ファイル名) (Get-Content ファイル名) | fc | diff |
19 | | ← | robocopy | rsync |
20 | | New-item -ItemType File ファイル名 | type null > ファイル名 | touch |
21 | | (Get-Item ファイル名).LastWriteTime = (Get-Date) | copy ファイル名 + | touch |
22 | プロセス | Get-Process | tasklist | ps |
23 | | Stop-Process | taskkill | kill |
24 | | Get-Process | Where-Object ($_.ProcessName -eq "プロセス名") | % { Stop-Process $_.Id } | taskkill /im | killall |
25 | 文字列操作 | Select-String -CaseSensitive | findstr | grep |
26 | | Select-String | findstr /i | grep -i |
27 | | Get-Content ファイル名 | Sort-Object | sort | sort |
28 | | Get-Content ファイル名 | Sort-Object | Get-Unique | - | sort | uniq |
29 | | 文字列.Replace("置換前文字列", "置換後文字列")
| - | tr |
30 | 日付・時刻 | Get-Date -Format yyyy/MM/dd | date /t echo %DATE% | date '+%Y/%m/%d' |
31 | | Get-Date -Format hh:mm:ss | time /t echo %TIME% | date '+%T' |
32 | システム | [Environment]::OSVersion | ver winver systeminfo | findstr /b "OS" | uname -a |
33 | | Get-WMIObject Win32_Processor | Format-List | systeminfo | cat /proc/cpuinfo |
34 | | Get-WMIObject Win32_PhysicalMemory | Format-List | systeminfo | cat /proc/meminfo |
35 | | - | logman | sar |
36 | | - | logman | vmstat |
37 | | - | logman | iostat |
38 | | Get-Help コマンドレット | コマンド /? | man |
39 | | ← | hostname | hostname |
40 | | ← | taskmgr | top |
41 | 環境・シェル関連 | Exit-PSSession | exit | exit |
42 | | Get-ChildItem env: | set | env |
43 | | Get-ChildItem env: | set | printenv |
44 | | Write-Host | echo | echo |
45 | | Clear-Host | cls | clear |
46 | | Set-Alias New-Alias | doskey 別名=コマンド | alias |
47 | | Get-History | - | history |
48 | | Get-Random | %RANDOM% | $RANDOM |
49 | | Get-Command | where | which |
50 | | $lastexitcode | %ERRORLEVEL% | $? |
51 | | $PID | - | $$ |
52 | ユーザ | ← | query user query user /server:ホスト名 | who -u |
53 | | ← | whoami | who am i |
54 | ネットワーク | ← | ipconfig /a | ifconfig -a |
55 | | ← | netstat | netstat |
56 | | ← | arp | arp |
57 | | ← | ping | ping |
58 | | ← | tracert | traceroute |
59 | | ← | nslookup | nslookup |
60 | その他 | $NULL | NUL | /dev/null |
61 | | Start-Sleep | timeout /t 秒 /nobreak > nul | sleep |