Creating COM and .NET Objects with Windows PowerShell 2

Part of the Windows PowerShell 2 For Dummies Cheat Sheet

PowerShell 2 enables you to automate your Windows operating system, which entails dealing with objects: COM objects are created using the New-Object method with the -comobject parameter, whereas .NET objects are created by enclosing the class name in square brackets. An example of each follows:

$objWord = New-Object -comobject "Word.Application"
$objWord.visible = $true
$objWord.Quit
$ips = [System.Net.Dns]::GetHostAddresses("www.dummies.com")
$ips | Select-Object IPAddressToString
blog comments powered by Disqus

SERIES
Windows PowerShell 2 For Dummies Cheat Sheet

Advertisement

Inside Dummies.com