One Step Further: Working with New-Object

In this exercise, we create a couple of objects.

  1. Start Windows PowerShell by using Start | Run | Windows PowerShell. The PowerShell prompt will open by default at the root of your Documents And Settings.

  2. Create an instance of the wshNetwork object by using the New-Object cmdlet. Use the comobject argument, and give it the program ID for the wshNetwork object, which is "wscript.network". Store the results in a variable called $wshnetwork. The code looks like the following:

    $wshnetwork = new-object -comobject "wscript.network"
  3. Use the EnumPrinterConnections method from the wshNetwork object to print out a list of printer connections that are defined on your local computer. To do this, use the wshNetwork object ...

Get Microsoft® Windows PowerShell™ Step By Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.