试图对两个值执行-EQ,但是不起作用。查看Get-Variable之后,我注意到值后面有三个点。像这样
0x0...
应该为0x0
,所以如何清除变量以使其不包含三个点?
这是我执行的代码和步骤:
$log = (Get-EventLog -LogName Security -Newest 1 -InstanceId 4769).message
$EID4769 = "Account Name:\s+(?<AccNam>.*)[\s\S]+Service Name:\s+(?<WorNam>.*)[\s\S]+Client Address:\s+(?<IPAdd>.*)[\s\S]+Failure Code:\s+(?<ErrCod>.*)"
if ($log -match $EID4769) {
$AccountName = $matches['AccNam']
$WorkstationName = $matches['WorNam']
$IPAddress = $matches['IPAdd']
$ErrorCode = $matches['ErrCod']
}
$ErrorCode
0x0
$ErrorCode -eq '0x0'
False
Get-Variable
Name Value
---- -----
ErrorCode 0x0...
$ErrorCode -eq '0x0...'
False