Welcome To Myself

Hello all,

My name is Rick Westrate. Aaron Sweemer has been gracious enough to invite me to contribute some I (hopefully) insightful content to his snazzy new site. Now what in the world would qualify me to comment on the world of virtualization you ask? Let’s set the record straight. I certainly do not claim to be the authority on the subject. However, I do believe my 11 years of experience in the enterprise IT industry and my position with my employer, VMware, provides me with an occasional unique perspective on the virtualization industry. Before joining VMware, I worked as a consultant focused on a wide array of datacenter technologies ranging from VMware virtualization, large Citrix PS implementations, (woops, it’s called XenApp these days), and storage arrays implementations (primarily EMC). These days, I work as a Systems Engineer in West Michigan, focused on large Enterprise Accounts. I travel around spending time with customers, listening to their problems, concerns, and needs. I then work with them on walking through and understanding the many game-changing solutions VMware provides. It’s certainly an exciting time to be in the virtualization industry. The pace of innovation, and change is amazing. SO, hello to you all! Hang on tight and stay tuned. I will be publishing some additional content soon. I look forward to interacting with everyone and hearing what you have to say!

Powershell and the VI Toolkit for Windows

I’ve been using Perl for close to 10 years now, so my natural tendency has been to use Perl when creating automation scripts for virtual infrastructure.  Now for some reason, there has been a significant increase in the amount of questions I get about scripting repetitive virtual infrastructure tasks.  In fact, just yesterday a customer asked me “is there an easy way to rescan the HBA’s in all off my (many) hosts?”  With the GUI, this could translate into 100s of clicks and a very boring hour or more of work.  Of course, a properly written script could easily handle this, requiring a mere 30 seconds of his time.  And again, a few months ago I would have answered the question by pointing him towards Perl.

But recently there has been a lot of buzz around Powershell and the VI Toolkit for Windows.  So I started checking it out a few months ago and thus far, I’m very impressed.  Check this out, a script that would solve the HBA rescan problem I just described could be as simple as this …

Connect-VIServer –Server  ip_of_vc -User “username” -Password “password
Get-VMHost | Get-VMHostStorage –RescanAllHBA

Or, if you’d like the script to prompt you for the VirtualCenter IP, username and password, it would look like this …

$vc = Read-Host “Enter the IP address of your VirtualCenter server”
$un = Read-Host “Enter your username”
$pw = Read-Host “Enter your password”
Connect-VIServer –Server  $vc -User $un -Password $pw
Get-VMHost | Get-VMHostStorage –RescanAllHBA

Pretty easy, huh?  Here is a quick little script I wrote for a customer that’s standing up a large number of ESX servers and they didn’t want to manually add all of them to VirtualCenter.  The DNS names of their ESX servers were computernamexxx.domain.com.

## Gather info and connect to VC
$vc = Read-Host “Enter the IP address of your VirtualCenter server”
$un = Read-Host “Enter your username”
$pw = Read-Host “Enter your password”
Connect-VIServer -Server $vc -User $u -Password $p
Write-Host “Connected to VirtualCenter ($vc)”

## List available datacenters and select which one to add the ESX servers
$adc = Get-Datacenter
Write-Host $adc
$dc = Read-Host “Which Datacenter?”

## Gather the number of ESX hosts, the root password and the first ESX to be added
$nh = Read-Host “How many hosts are we connecting?”
$rp = Read-Host “What is the root password of the hosts?”
[int]$start = Read-Host “What is the number of the first host (computernamexxx.domain.com)?”
$stop = $start + $nh

## Add them to VC
while ($start -le $stop) {

$x = “{0:0##}” -f $start   ## <– leading zeros
$myhost = “computername” + “$x” + “domain.com”
Add-VMHost $myhost -Location (Get-Datacenter $dc) -User root -Password $rp
Write-Host “$myhost is now connected to VirtualCenter ($vc)”
$start++
}

Or, here’s a quick and dirty one liner I used to remove the VLAN ID’s on a port group.  If you want to add or change the VLAN ID, rather than remove it, simply change the 0 at the end of the line to the actual VLAN ID.

$hosts = Get-VMHost; foreach ($x in $hosts) {get-virtualportgroup -host (get-vmhost $x)  -name “portgroup” | set-virtualportgroup -vlanid 0}

As you can probably tell, I’ve decided that I like Powershell and the VI Toolkit for Windows.  It’s VERY handy.  In fact, I’m thinking of collecting my favority scripts, tools and links and compiling a separte page.  So look for that coming soon.  For now, here are some essentials:

Happy scripting! :)