Home > Virtualization > PowerCLI Script – With Voice

PowerCLI Script – With Voice

February 19th, 2010 Jase Leave a comment Go to comments

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″;
Categories: Virtualization Tags: , , ,
  1. February 19th, 2010 at 15:31 | #1
  2. Nick
    February 24th, 2010 at 14:33 | #2

    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?

  3. March 5th, 2010 at 09:11 | #3

    @Nick

    Technically, you could use the method in this post: Update VMware Windows Guest DNS and WINS through PowerCLI. You would just have to modify the script to use netsh to update IP settings.

  1. February 19th, 2010 at 21:48 | #1
Please leave these two fields as-is:

Protected by Invisible Defender. Showed 403 to 947 bad guys.