Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning PowerCLI for VMware VSphere
  • Table Of Contents Toc
Learning PowerCLI for VMware VSphere

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
3.9 (15)
close
close
Learning PowerCLI for VMware VSphere

Learning PowerCLI for VMware VSphere

3.9 (15)
By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
close
close
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1
Index

Using COM objects


You can also use the New-Object cmdlet to create an instance of a COM object. COM objects were used a lot in VBScript. In PowerShell, you can still use them to do things that you cannot do in native PowerShell. The following example will use the SAPI.SpVoice COM object to output a text as voice. It will say "The script is finished." Append this piece of code at the end of your PowerCLI script and you will hear your computer say that the script is finished. This way, you don't have to keep watching your computer screen. Isn't this cool?

PowerCLI C:\> $Voice = New-Object -ComObject SAPI.SpVoice
PowerCLI C:\> $Voice.Speak("The script is finished.") | Out-Null

You can get a list of all of the COM objects on your computer with the following PowerShell code:

Get-ChildItem -Path HKLM:\Software\Classes -ErrorAction ` SilentlyContinue |
Where-Object {$_.PSChildName -match '^\w+\.\w+$' –and `
  (Get-Itemproperty "$($_.PSPath)\CLSID" -ErrorAction ` SilentlyContinue)} |
Format...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning PowerCLI for VMware VSphere
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon