はじめに

WSLから呼び出す例

# powershell 7
pwsh() {
    '/mnt/c/Program Files/PowerShell/7/pwsh.exe' "$@"
}

# powershell 5.1など
pwsh() {
    '/mnt/c/Windows/system32/WindowsPowerShell/v1.0/powershell.exe' "$@"
}

ps -ef

ProcessName順(1行で表示)

pwsh -Command 'Get-Process | Select-Object Id, ProcessName, @{Name="CommandLine";Expression={(Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine}} | Out-String -Width 4096'
   Id ProcessName          CommandLine
   -- -----------          -----------
 8596 AdobeCollabSync      "C:\Program Files\Adobe\Acrobat DC\Acrobat\AdobeCollabSync.exe" --type=collab-renderer --proc=8956
 8956 AdobeCollabSync      "C:\Program Files\Adobe\Acrobat DC\Acrobat\AdobeCollabSync.exe"
 5308 AggregatorHost
 8472 ApplicationFrameHost C:\Windows\system32\ApplicationFrameHost.exe -Embedding
 4656 armsvc
13236 bash                 "C:\cygwin64\bin\bash.exe" --login -c 'pproxy -v -l http+socks4+socks5://0.0.0.0:1080/ -r socks5://nttcs.ecl.ntt.co.jp:1080'
 2932 conhost              \??\C:\Windows\system32\conhost.exe 0x4

Id順に並べ替え(Out-String だと表示が崩れるので Format-List に変更)

pwsh -Command 'Get-Process | Sort-Object Id | Select-Object Id, ProcessName, @{Name="CommandLine";Expression={(Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine}} | Format-List'
Id          : 0
ProcessName : Idle
CommandLine :

Id          : 4
ProcessName : System
CommandLine :

Id          : 184
ProcessName : Secure System
CommandLine :

Id          : 300
ProcessName : Registry
CommandLine :

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-07-19 (金) 07:26:31