GetObject


Definition: Returns a reference to an Automation object from a file.

 

OK, we’ll level with you: we’re taking the easy way out on this one. Although Windows PowerShell does not include a GetObjectcommand, it ispossible to load the Microsoft.VisualBasicassembly and then use the Interactionclass and its GetObject method:

 

[ reflection.assembly]: : LoadWithPartialName("' Microsoft.VisualBasic")
$a= [ Microsoft.VisualBasic.Interaction]:: GetObject("WinNT://atl-ws-01/Administrator")

 

That part’s easy. To actually usethis object reference is far more complicated, requiring the use of binding flags and the InvokeMembermethod, and, well, it goes way beyond what we can cover in this introductory manual.

 

The best thing to do?Assume that there is no GetObjectequivalent and forget about it. The second best thing to do: Check this Web site for an example of using the Visual Basic .NET GetObjectmethod from within Windows PowerShell.