$version = Get-EventLog
-Newest 1
-ComputerName $systemnummer 'Symantec Endpoint Protection Client'
-Message "*Version*" | Select message
[string]$version = $version
$version = $version.Split(":")
获取事件日志条目$版本包含以下字符串后: "@{Message=New virus definition file loaded. Version: 150317001.}"
PowerShell的string.split
我怎么可以分割字符串,仅保留号码“150317001”?
我试过,但我很抱歉...您的$版本似乎是空 – 2015-03-19 12:18:56
不要投给'[字符串]'做我添加的代码之前,见好就收'$ version' as它是从'Get-Eventlog'返回的时候' – arco444 2015-03-19 12:28:39
考虑使用'Select -expand message'来返回字符串。删除一个障碍。 – Matt 2015-03-19 12:33:45