Jul 16 2023 09:26 AM
If I run the following command remotely, the starttime comes back as blank
Get-Process -ComputerName myComputer | select name, id, starttime | select-string myProcess
However if I run it on the target machine it works fine and I can get the starttime. How can I get the starttime of a server process from a remote computer?
Jul 16 2023 01:00 PM
SolutionHi @peter_s,
To remotely retrieve the start time of a process using PowerShell, you can utilize the Invoke-Command cmdlet. When running the Get-Process command remotely, the StartTime property may not be available by default. you can try this code:
$computerName = "myComputer"
$processName = "myProcess"
$startTime = Invoke-Command -ComputerName $computerName -ScriptBlock {
param($procName)
Get-Process -Name $procName | Select-Object -ExpandProperty StartTime
} -ArgumentList $processName
Write-Host "Start Time: $startTime"
In this code, the Invoke-Commandis used to run the Get-Process command remotely on the specified $computerName. The script retrieves the process using the provided $processName parameter and selects the StartTime property. Finally, the start time is stored in the $startTime variable and displayed.
Invoke-Command (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn
über Remote - PowerShell | Microsoft Learn
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Jul 16 2023 01:41 PM