简体   繁体   中英

How to find the PID of a running command in cmd/powershell over SSH?

Something similar to echo $$;python my_script.py > out.log

Expected output:

using cmd_command or powershell command

If you are running PowerShell, the PID variable is available.

PS C:\> $PID
8420
PS C:\> Get-CimInstance -Class CIM_Process | Where-Object { $_.ProcessId -eq $PID }

ProcessId Name     HandleCount WorkingSetSize VirtualSize
--------- ----     ----------- -------------- -----------
8420      pwsh.exe 1004        119939072      2204255981568

See the other members available using:

Get-CimInstance -Class CIM_Process | Where-Object { $_.ProcessId -eq $PID } | Format-List -Property * -Force

or

Get-CimInstance -Class CIM_Process | Get-Member

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM