Scripting With PowerShell
COM Objects

Introduction to Scripting COM Objects with PowerShell

ComObject, or plain COM, increases the range of PowerShell activities. One way of looking at COM objects is as a mechanism for PowerShell to launch programs, for example, mimicking the RUN command. Another way of looking at ComObjects is performing the role previously undertaken by VBScript. For both those tasks, scripting with COM objects gives you a rich selection of options. The bonus of using PowerShell rather than VBScript is that you need fewer commands.

The secret of manipulating COM objects is starting with the command: New-Object -COM. What comes next depends on which type of object you need. Here are examples of creating, then manipulating ComObject with $variables:-

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

New-Object -Com | Get-Member

Let us investigate the properties of the -Com object. At first, Get-Member appears not work, even help seems unsupportive. Fortunately, all that is missing is the name of the -Com object that you wish to research. For example:

Guy Recommends: Free WMI Monitor for PowerShell

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft’s operating systems. Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.

Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try – it’s free.

The ComObject family of commands add important capabilities to PowerShell. For example, creating network objects means that you don’t have to revert to VBScript when you need to map network drives. Another way of looking at the -ComObject command is as a PowerShell method of accessing the Run dialog box programmatically.