简体   繁体   English

使用PowerShell在远程计算机上运行进程的开始时间

[英]Start time of a process running on remote machine using powershell

I want to get the start time of a process running on remote machine using powershell. 我想使用PowerShell获取在远程机器上运行的进程的开始时间。 On my local computer I get it simply by using get-process $processname | select StartTime 在我的本地计算机上,我只需使用get-process $processname | select StartTime就可以得到它 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 get-process $processname -computername $server1 | select StartTime but this is returning me nothing. get-process $processname -computername $server1 | select StartTime但这不会给我任何回报。

Please suggest any better way. 请建议任何更好的方法。

Using WMI . 使用WMI This code return start time of powershell.exe process: 此代码返回powershell.exe进程的开始时间:

$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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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