gpt4 book ai didi

powershell - 如何在 PowerShell 中获取进程启动时间

转载 作者:行者123 更新时间:2023-12-02 22:12:45 27 4
gpt4 key购买 nike

如何在 PowerShell 中获取进程启动时间?

我在 PowerShell 提示符下试过这个:

(Get-Process MyProcessName).StartTime.ToString('yyyyMMdd')

这是我得到的错误:
(Get-Process MyProcessName).StartTime.ToString('yyyyMMdd')

You cannot call a method on a null-valued expression.
At line:1 char:1
+ (Get-Process MyProcessName).StartTime.ToString('yyyyMMdd_h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

但是当我执行 Get-Process MyProcess 时,我看到了我的流程:
> Get-Process MyProcess

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
2906 132 81136 79132 889 20656 myprocess

当我执行 'Get-Date -format 'yyyyMMdd' 时,它返回 '20151207',所以我认为日期格式是正确的。

最佳答案

作为单线,您可以使用:

Get-Process ProcessName | select starttime

关于powershell - 如何在 PowerShell 中获取进程启动时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34142041/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com