It seems that OutVariable is broken when using the Exchange 2010 cmdlets. Is it just my server or is this the case for everyone? I observed the following --
get-mailbox jdoe -OutVariable asdf | out-null
$asdf.getType()
You cannot call a method on a null-valued expression.
At line:1 char:14
+ $asdf.getType <<<< ()
+ CategoryInfo : InvalidOperation: (getType:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
In the example above, $asdf
is never created and get-mailbox jdoe
absolutely returns something.
get-childitem -OutVariable asdf | out-null
$asdf.getType()
[PS] C:\temp>$asdf.getType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True ArrayList System.Object
In this example, $asdf
is created as expected since get-childitem
is not an Exchange 2010 cmdlet.