Forum Discussion

peter_s's avatar
peter_s
Copper Contributor
Jul 16, 2023
Solved

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 t...
  • LeonPavesic's avatar
    Jul 16, 2023

    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 $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

Resources