Trying to do an -EQ on two values but it's not working. After looking at Get-Variable I notice the values have three dots after it. Like this
0x0...
It should be 0x0
so how do I clean up the variable so it doesn't contain the three dots?
Here is the code and steps I did:
$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