我有一个像这样的PowerShell脚本:
$owners = @{}
gwmi win32_process |% {$owners[$_.handle] = $_.getowner().user}
get-process | select processname,Id,StartTime,@{l="Owner";e={$owners[$_.id.tostring()]}}
我想将StartTime
格式化为24h格式并且不显示秒数。我该怎么做?
答案 0 :(得分:2)
试试这个:
$owners = @{}
gwmi win32_process |% {$owners[$_.handle] = $_.getowner().user}
get-process | select processname,Id,@{l="StartTime";e={ get-date $($_.starttime) -f "dd/MM/yy HH.mm" }},@{l="Owner";e={$owners[$_.id.tostring()]}}