January 19, 2022

PowerCLI Script – With Voice

I was looking at some tweets, and noticed one from @ScriptingGuys about how to add voice to a PowerShell script.  Here is the actual tweet: http://twitter.com/ScriptingGuys/statuses/9343448757

Here’s the syntax in an example:
(New-Object -ComObject sapi.spvoice).speak(“Greetings Professor Falken”)
(New-Object -ComObject sapi.spvoice).speak(“Shall we play a game”)

So I took one of my PowerShell scripts, and modified it.  I chose my PowerCLI: NFS Settings for vSphere (NetApp NFS Recommendations) script, because it is a short script, and it was easy to update.

# Update TCP and NFS Advanced Configuration Settings for vSphere w/Voice
# Author: Jase McCarty
# Date: 2/19/2010

<span style="color: #0000ff;">(New-Object -ComObject sapi.spvoice).speak("What is the ESX Host Name or IP Address")</span>
$ESXHOST = Read-Host “Enter ESX Host Name or IP”
Connect-VIServer $ESXHOST

<span style="color: #0000ff;"> (New-Object -ComObject sapi.spvoice).speak("Now updating TCP and NFS Advanced Configuration Settings on host " + $ESXHOST)</span>
Write-Host “Updating TCP and NFS Advanced Configuration Settings on host ” + $ESXHOST

# Update TCP Settings
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name Net.TcpipHeapSize  -Value 30
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name Net.TcpipHeapMax  -Value 120

# Update NFS Settings (For ESX 3.5, MaxVolumes should be 32)
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name NFS.MaxVolumes  -Value 64
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name  NFS.HeartbeatMaxFailures -Value 10
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name  NFS.HeartbeatFrequency -Value 12
Set-VMHostAdvancedConfiguration -VMHost $ESXHOST -Name  NFS.HeartbeatTimeout -Value 5

(New-Object -ComObject sapi.spvoice).speak("NetApp Settings Complete")

Pretty cool addition.  A good use of this, (as well as text prompts) would be when running commands against vCenter, “vocally” indicating changes to objects (hosts, clusters, guests, etc) as they are being modified.

This might be a little much, but when running a script against many objects, it would not require having to watch the screen for output while the script is running.  Attention could then be focused on other things.

I don’t know if anyone is going to use this little addition, as it does take extra code.  Administrators who approach scripts like I do (with many status messages and the like) might find this as a cool addition.

Figured I’d share.

$NVPG = Get-VMHost $ESXHOST | Get-VirtualSwitch -Name “vSwitch0” | New-VirtualPortGroup -Name “VLAN100” -VLanId “100”;

4 thoughts on “PowerCLI Script – With Voice

  1. Jase,

    When I clone VM’s the IP aliases attached to the NIC in Windows Server 03 advanced networking settings get deleted; thus forcing me to enter them in by hand every time which is annoying and time consuming. This is a fault of Sysprep it seems.

    Any idea on how to write a script that will punch in the IPs based on hostname?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.