It's taken me way too long to get into PowerShell 3, I guess opportunity hasn't shown it's self until now and so, here, my V3 journey begins.
I was asked to debug a script that would run fine in PS v2 and not in v3. The issue was a that a variable length was being checked and was failing in v3. This is why...
In v2 if a variable is undefined, this test returns false
PS C:\windows\system32> $var.length -eq 0
False
In v3 the same test returns true....
PS C:\windows\system32> $var.length -eq 0
True
Not a biggie, but as in this case, a script has broken so something to consider!
cheers
Adam
I was asked to debug a script that would run fine in PS v2 and not in v3. The issue was a that a variable length was being checked and was failing in v3. This is why...
In v2 if a variable is undefined, this test returns false
PS C:\windows\system32> $var.length -eq 0
False
In v3 the same test returns true....
PS C:\windows\system32> $var.length -eq 0
True
Not a biggie, but as in this case, a script has broken so something to consider!
cheers
Adam
Comments
Post a Comment