IsObject


Definition: Returns a Boolean value indicating whether an expression references a valid Automation object.

 

That’s a good question: how canyou tell whether or not a variable is an object reference; that is, how can you tell whether a variable is a pointer to a COM object or a .NET object? Well, one way is to invoke the –isparameter and see if the variable really isan object. For example, in the following two commands we create an object reference named $a. We then check to see whether or not $ a isan object reference, with the resulting value (True or False) stored in the variable $b:

 

$a = new-object - comobject scripting.filesystemobject
$b = $a -is [object]

 

When you run this command and then echo back the value of $b you should get the following:

 

True

 

As we intimated, .NET objects will also be identified as objects using this command.