13.2. Working with Specific Applications
The following sections describe how to access a number of commonly used COM applications and carry out some tasks from Windows PowerShell. The extent of useful automation you can achieve with any individual COM object depends on the members that are exposed to you and your knowledge of those members. If you want to explore the possibilities of a particular unfamiliar COM object, use the get-member cmdlet to find which methods and properties you can access.
13.2.1. Working with Internet Explorer
Internet Explorer is one of the most easily manipulated COM applications. To launch an instance of Internet Explorer, type the following command:
$ie = new-object -comobject InternetExplorer.application
After a short pause it seems that nothing has happened, since the PowerShell cursor is displayed. No new Internet Explorer window is displayed. However, if you type a command like
$ie.visible
the value False is displayed on the console so you know that the $ie object exists and has a visible property. If the $ie object or its visible property didn't exist, you would expect Windows PowerShell to either display nothing (assuming that the $erroraction variable was set to SilentlyContinue) or display an error message saying that the object or property didn't exist. I discuss errors in Chapter 17.
You can explore the properties of the $ie object by using the command
$ie | get-member -memberType property
and the information shown in Figure 13-1 is displayed, ...
Get Professional Windows® PowerShell 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.