- 1 year ago
Poweshell alias for startTIME of Process
To create a PowerShell alias for retrieving the start time of a process, you can define a function and then create an alias for that function. Here's an example:
powershellfunction Get-ProcessStartTime {
param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('Name')]
[string]$ProcessName
)
Get-Process -Name $ProcessName |
Select-Object -Property Name, StartTime
}
New-Alias -Name psstart -Value Get-ProcessStartTime
In the above code, we define the Get-ProcessStartTime
function, which takes a process name as an input parameter and uses the Get-Process
cmdlet to retrieve the process information. It then selects the Name
and StartTime
properties of the process.
Finally, we create an alias psstart
using the New-Alias
cmdlet. This alias allows you to use the shorter psstart
command instead of typing Get-ProcessStartTime
every time you want to retrieve the start time of a process.
After running the code, you can use the psstart
alias followed by the process name to retrieve the start time. For example:
powershellpsstart -ProcessName chrome
This will display the name and start time of the "chrome" process. You can replace "chrome" with the name of any other process you want to retrieve the start time for.
Feel free to modify the function and alias to suit your specific requirements.