I want to get the start time of a process running on remote machine using powershell. On my local computer I get it simply by using get-process $processname | select StartTime
get-process $processname | select StartTime
.
I tried using get-process $processname -computername $server1 | select StartTime
get-process $processname -computername $server1 | select StartTime
but this is returning me nothing.
Please suggest any better way.
Using WMI
. This code return start time of powershell.exe process:
$a = gwmi win32_process -computername $server1| ? { $_.name -eq "powershell.exe" }
$a | % { $_.ConvertToDateTime( $_.CreationDate )}
PS> $StartTime= @{n='StartTime';e={$_.ConvertToDateTime($_.CreationDate)}}
PS> gwmi win32_process -cn $server1 -filter "Name='$processname' AND CreationDate IS NOT NULL" | select Name,$StartTime
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.