Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Why does this fail the if statement check

$
0
0

$value=0

if (($value-ne"") -and ($value-ne$null)) {

"Value is {0}" -f $value

}

else {

"Null or Empty value"

 

This returns Null or Empty Value. Why? 0 is a legit variable value. Causing some issues with a database update script I've been writing since our DB doesn't allow any nulls.

 

Using Powershell 3

 

Thanks


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images