Forum Discussion
peter_s
Jul 16, 2023Copper Contributor
Remotely get the start time of a process through Powershell
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?
Hi 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 $processNameWrite-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
- LeonPavesicSilver Contributor
Hi 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 $processNameWrite-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
- peter_sCopper ContributorOkay got it! I was missing computer name and just found out that the process name is case sensitive
invoke-command -computerName myServer -ScriptBlock {Get-Process -name myProcess | select name, id, starttime }