Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

Converting VBScript's IsObject Function


Windows PowerShell


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

IsObject

That’s a good question: how can you 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 -is parameter and see if the variable really is an object. For example, in the following two commands we create an object reference named $a. We then check to see whether or not $a is an 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.


Return to the VBScript to Windows PowerShell home page

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.