所以我得到了这段代码:
$events = Get-WinEvent -FilterHashtable @{logname='application'} |
Select Id,ProviderName,Message,TimeCreated
它给了我以下输出:
Id ProviderName Message TimeCreated
-- ------------ ------- -----------
327 ESENT svchost (664) The database engi... 28.07.2014 14:46:24
326 ESENT svchost (664) The database engi... 28.07.2014 14:46:24
8224 VSS The VSS service is shutting dow... 28.07.2014 14:40:23
903 Microsoft-Windows-Security-SPP The Software Protection service... 28.07.2014 14:39:40
16384 Microsoft-Windows-Security-SPP Successfully scheduled Software... 28.07.2014 14:39:40
...
如何将日期格式更改为" Full date and time (long date and long time) using universal time"喜欢 2007年8月30日星期四下午6:21:52 ?
答案 0 :(得分:1)
可能有几种方法可以做到这一点。这是一个例子。
$events = Get-WinEvent -FilterHashtable @{logname='application'} |
Select-Object Id,ProviderName,Message,@{Name='TimeCreated';Expression={[String]::Format("{0:U}", $_.TimeCreated)}}
答案 1 :(得分:1)
这是另一种方式:
$events = Get-WinEvent -FilterHashtable @{logname='application'} |
Select Id,ProviderName,Message,@{Label = "TimeCreated"; Expression = {Get-Date $_.TimeCreated -Format U}}
答案 2 :(得分:1)
这有效:
$events = Get-WinEvent -FilterHashtable @{logname='application'} |
Select-object Id, ProviderName, Message, @{Name='TimeCreated';Expression={$_.TimeCreated.tostring('F')}}
以下是您可以使用的标准格式字符串:
http://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx