Hello,
I have the following code inside a ps1 file:
---
$errorString = ($root.fault.value.struct.member | Where-Object { $_.name -match "faultString" }).value.string
if(($errorString.length) > 0){
Write-Debug ("ERROR_NOT_PRINTED: " + $errorString )
}
Write-Debug ("ERROR: length: " + ($errorString.length) )
Write-Debug ("ERROR: " + $errorString)
The debug output shows:
DEBUG: ERROR: length: 61
DEBUG: ERROR: Parameter that is supposed to be floating point number is not
Why doesn't it show the ERROR_NOT_PRINTED string? Its length is 61 which is bigger than zero ...
You'd better double check what operation you want.
I believe you want
if($errorString -gt 0) {
And if you check (51 > 0) and assign it to a variable, it turns into...
$null
Check your current directory, and you'll find out that you've created a file name 0 with the string length in it.
check out the about_Comparison_operators: http://technet.microsoft.com/en-us/library/dd315321.aspx
Powershell does not use ">", instead it uses the "-gt" operator.