Powershell 让WinEvent返回字符串?
要从get WinEvent获取字符串数组吗?我现在拥有的是Powershell 让WinEvent返回字符串?,powershell,Powershell,要从get WinEvent获取字符串数组吗?我现在拥有的是 Get-WinEvent -ComputerName bcdc01 -FilterHashtable @{logname='security';id=4771;data=$Localusername} | Select-Object -Property timecreated, @{Name='computername';expression={$_.properties[6].value.Split(':')[3]}} 是
Get-WinEvent -ComputerName bcdc01 -FilterHashtable @{logname='security';id=4771;data=$Localusername} |
Select-Object -Property timecreated,
@{Name='computername';expression={$_.properties[6].value.Split(':')[3]}}
是否可以将其作为字符串数组或类似的内容返回?使用
Foreach对象和字符串格式化:
Get-WinEvent -ComputerName bcdc01 -FilterHashtable @{logname='security';id=4771;data=$Localusername} | Foreach-Object {
'{0}: {1}' -f $_.timecreated,$_.properties[6].value.Split(':')[3]
}
(注意:我无法测试您的属性提取)。如何…|%{out String}
?