IsNull


Definition: Returns a Boolean value that indicates whether an expression contains no valid data (Null).

 

It’s often useful to know whether or not a value is Null; scripterswho have worked with Active Directory have often run into problems when trying to do something as seemingly-trivial as echo back the value of a property, at least if that property turns out not to havea value. In Windows PowerShell you can check for a Null value simply by using the - eqcomparison operator to compare a variable with the system variable $Null. For example, this command compares $b to $Null, and stores the results of that comparison in $a:

 

$a = $z - eq$null

 

When you run this command and then echo back the value of $ a youshould get the following, assuming, of course, that $z really isNull:

 

True

 

If you then use a similar command to determine whether or not $ a isNull (i.e., $a – eq$null) you should get back False; that’s because $a isn’tNull.