PowerCLI: Speed boost, Find VM Snapshots by Name.

I use NetApp SnapManager for Virtual Infrastructure(SMVI) to back up 95% of my environment. SMVI isn’t perfect, and it’s kinda a pain, but it gives me the ability to back up 100-250 vm’s in less than 10min! Well the actual NetApp snapshot takes seconds. The rest of the time is spent waiting on ESX snapshots. The only real downside here is from time to time SMVI will fail to delete the ESX snapshots. I have been using PowerCLI to find and delete these snapshot, but the cmdlets are just too slow, for what I’m trying to do. I’ll post my Finalized SMVI cleanup script later. Until then, I give you finding snapshots really fast!

Read more

PowerCLI: VM displayName -ne Name

If you were lucky enough to get a hold of @jasonboche vCalendar then this morning you were greeted with a tip regarding the DisplayName of a VM not matching it’s actual path.   As someone who has ran rm -rf  on more than one running vm because of this very issue.**  I will personally attest to why you should care about this!  Jason includes a link to Dominic’s solution in the calendar, but I’m not crazy about perl. So I wrote my own, PowerCLI find any VM with a naming issue.

So what does that do? Well for speed we start with Get-View, and only retrieve the Config property for each VM. Then we pass that collection through Where-Object. This is where PowerShell earns it’s name.

So -match will perform a regular expression comparison operation, So here if the VmPathName looks anything like vm/vm.vmx -match will return $true, and that object will be passed down the pipeline. That however is only part of the story. When PowerShell matches something with a regex it stores the results in $Matches. This means that we can easily look that data up later. In addition I’m naming my matches. if you look in my regex you’ll notice (?<folder>.+?). The ?<folder> will apply the parameter name “folder” to anything that is matched inside the parenthesis, How cool is that!

From there it becomes real easy to see what I’m doing. I compare the displayName with both the Folder name, and the name of the vmx. Then I pass anything that didn’t match to the Get-VIObjectByView Cmdlet.

So how did it do? Well I just scanned 600 VM’s in less than 20 sec, and found two problem children. There you have it, my PowerCLI vCalendar solution for September 10th, 2009! I’m really looking forward to the rest of this calendar, and all the possible automation goodness.

~Glenn

**Note your not screwed if you delete a running VM, take a deep breath, and DON’T power the VM off!  You’ll need to recreate several files, but you have time.  ESX/vSphere have a lock on everything the VM needs to run.

PowerCLI: Watch for VMHost Reboot

From time to time I try and update all bios/firmware/etc. While VMotion makes this all but a cinch, evacuating every host in succession puts quite a strain on DRS.   Therefore,  I try and patch everything when installing uudates.  I’ve developed my own little technique where I let VUM do it’s thing.  Catching the Host in the middle of the reboot, and update everything else.  While the actual update methodology changes from OEM to OEM.  I use the same simple little script for vSphere/ESX.  Basically, when I see the remediation task start for a host I kick this function off, “watching” that host, and walk away. Then when vCenter registers a VMHost reboot on the Host this little guy let’s me know.

In case you didn’t already know `a will cause your motherboard to beep.  That loud annoying  “I can hear it two cubicles over” beep!

~Glenn

PowerCLI: Update VMX Configuration Parameters (in mass)

My Virtual Infrastructure was recently audited.  As part of my preparation for said audit I needed to verify that several extra configuration Parameters were set on every VM. Nothing ground breaking, this has all been covered here, and here. So why the repost, well I’m obsessed with scaling! I don’t like doing anything that I can’t use to the nth degree. Having said that I found two simple tweaks that dramatically increased the performance of these scripts.

If you ever find yourself using where-object move back up the pipeline… can you use a filter instead? Here I dramatically improved performance by leveraging the built-in filter capabilities of Get-View. I was also able to crank it up by simply switching from the ReconfigVM method to the ReconfigVM_Task method. Unless your performing some serial action, always, always use the task method. Offloading the babysitting to vCenter just makes sense! Finally, I loath text files, especially when they create a needless dependencies. Here I use a simple hashtable to embed my configuration in the script it self.

I successfully used this script to update over 500 vm’s in less than 4min!  Now that is what I call scale!  I know the security experts our there would argue that this is meaningless, b/c of this or that… all I know is I passes my audit with flying colors (didn’t have one ding on a VM’s configuration).

~Glenn

VMworld: Monday (Developer Day)

I can honestly say that I capitalized on a once in a lifetime opportunity.  For what ever reason Dev day was small this year.  There where only around 300 of us on the Developer track, and while the superstars of Virtualization were all looping through PTAP sessions I was attending small 15 to 1 labs with the likes of Steve Jin, Scott Herold, Carter Shanklin, LucD, and Cody Bunch…  You could say I learned a thing or two!

I started Monday with DS-13 it was suppose to be an Introduction to the vSphere Webservices SDK .  Unfortunately system errors prevented Steve from giving his full presentation!  My first lab I spent 45m trying to log into my virtual desktop.  It wasn’t a total lost though as I had Access to one of the authoritative sources on the VI API!  Shortly after Steve’s session I got a little side tracked, and picked my schedule back up with DS-16.

DS-16 Extending PowerCLI to Enterprise Applications with Virtualization EcoShell (VESI) presented by Scott Herold.  This session proved to be my favorite from Monday, and ran an hour long (in a good way)!  Good news, Scott and his team have done some fantastic work.  He is attempting to develop on demand.  Meaning as a demand for a feature/need starts to bubble up from the community either from the VESI forums or the usual places.  Scott fills that gap with a custom script extending the PowerCLI, or by modifying the user interface itself, extending VESI to better match the needs of the virtual administrator.  An example of the latter was on display where the VESI team has added the ability to transform any data set into rich charts. An important distinction with VESI is it is meant to enable the Virtualization Administrator NOT the VI Admin!  VESI will have full support for any Hypervisor/mgmt framework that the community has demand for.  It will also encompass any peripheral components of the virtual world.  Providing easy to use and context relevant access to any pain point whether it be storage, Network, AD… What ever the community needs!

The cynic out there will ask okay what does Vizioncore get out of this?  the answer, A single pane of glass that encompasses the entire virtualization ecosystem.  Oh yeah, and that pane of glass, it will one day serve as the front end for all of Vizioncores products!  The question was asked about pricing, and Scott insists that “VESI is and always will remain free”.  They need this framework for there own internal roadmap.  It’s extension to the community as a whole in my opinion will garnish them nothing but good will, and a built in user base.  Your probably asking yourself where’s the bad?

Politics… anyone from the PowerShell community will immediately recognize the VESI interface.  It’s our old friend PowerGUI, I asked Scott why something new, why not just build on top of PowerGUI.  His answer was speed, the PowerGUI team has a product roadmap, and there users need different things then Scotts.  He used the upcoming charts feature as an example.  It could take PowerGUI 18 months to get charts on there roadmap. PowerGUI is already hard at work putting out other fires.  By Scott forking PowerGUI he created a divisions but that division purchased an independent product roadmap.  It’s this roadmap that is enabling him to move with the Virtualization Community.  The sad part to me I don’t believe the division was truly necessary.  Why Scotts team couldn’t just develop those same features, injecting them into PowerGUI as needed, and thereby enhancing both products at once… that can only be political.  We all know how software works. There is no technical reason preventing this.  Alas while I think a best of both worlds super PowerGUI would have been better for everyone.  I for one am glad to have VESI in our tool belt. If your new to PowerShell or the PowerCLI check it out as Carter put it “VESI is the onramp to PowerCLI and PowerShell Scripting”… Couldn’t agree more!

Finally I ended Monday with a session on VIX.  while there is some really cool stuff coming in VIX there has been no change for the PowerShell community.  The latest version of VIX shipped just last week, and sadly 1.7 still offers no .Net/vi sdk interfaces. The .COM interface is critically crippled if you want to use it with vSphere, and overall your still forced to provide a username/Password to the guest OS.  Alas it’s not nearly as bad as I made it out to be! 😉

The 1.7 release added full support for vSphere 4.0, and the VIX team is currently evaluating SSIP/Certification based authentication for the guest.  As for how it will ultimately be extended into powershell it looks like either a .net class, or by extending the vi api.  Either way will be a win for powershell as we can easily extend either into first-class cmdlets!  The use case for VIX is a bit nitch, but when you need it nothing else will do!

An interesting tidbit if you’re super security cautious you can disable VIX by adding

“Guest.Command.Enabled”=”False”

to either the VM or the host.  Be aware that this WILL break upgrading of VMware tools, and Guest customization as they both use vix as the underlying technology!

So that’s Developer day at VMworld all in all I had a blast, and met the superstars of the VI API/vSphere automation community.  The Food was 10x better then what they’re serving here at VMworld, and I get a free license of vSphere!  All for $249 USD, if you’re interested in more advanced automation at the vi api level I highly recommend developer day. 

VMware this was a win, win… let’s try and keep it for the future.

~Glenn

VMware: VCP4

So there I was in-between sessions just after lunch at VMworld when someone on twitter mentioned a VCP button.  Being a big fan of badge bling I showed the post to Andrew, and asked some guys around us If any of them knew anything about it.  One had seen the button, but didn’t know where you got one or why.  This is where my Monday got a little sidetracked.  At first we headed down to the materials pickup where I caught John Troyer stealing buttons!  But they directed us to the customer service desk.

Andrew and I proceeded to the customer services desk to inquire, and were quickly informed that we needed to be VCP4.  Honestly, that should have been the end of it, but for whatever reason we decided to walk over and look for ourselves.  Next thing I know I’ve slapped down my AMEX and I’m sitting behind a person vue terminal!  Why is this significant?

I’ve never touched vSphere, no beta, no RC access… Nothing.. Heck I didn’t even review the configuration maximums before hand!  I took it totally off the cuff no prep at all, and  passed!  I have my VCP on VI 3, and I’ve kept up with vSphere via our wonderful bloggers.  In a month or so I should be the proud owner of a VCP 4 certification.  At this point I need throw a huge thank you over to John Troyer, because while I’ve never touched these features I have listened to extensive interviews/discussions covering every aspect or vSphere.  In many ways the VMware Communities Roundtable Podcast was my “what’s new what’s changed” course.  In addition  to that overview our community in particular Duncan. Scott, Boche, etc provided me with the real life reference implementations.

What I don’t have is the hands on experience, I lack the practical knowledge that comes from performing a real implementation (A.K.A. the part that matters).  So there you have it, everyone complained about the need for the class, and VMware listened.  My question to you is… should I be able pass that test.  Knowing the whole background would YOU accept my updated credentials?  Something to think about next time we start complaining about the need for a class.  Personally, I never would have upgraded if it weren’t for the grace period, so I for one am grateful, but is this what we really want?

Perhaps we can agree that I’m just that good..? I would say that I benefited from the world class engineers I studied by proxy.  Personally I believe all of the above to be true.  Perhaps we could agree that the VCP isn’t that big of a deal, that It’s not a VCDX…I passed the “I know what these do in theory” test. Not the “I know what these do in practice” test. we would then agree that we would test for those skills further up the stack. 

As a Microsoft Professional I’m very familiar with that type of system, but is that what we want? In theory it sounds like a better system, but there is no end once you start down that road.  Microsoft recently had to enact a master certification to find the real masters.  Think about that for a second… why do you need a test to prove ‘this guy really really knows what he’s doing’ shouldn’t the engineer certification handle that?   I don’t know the answer I just wanted to ask the question?

~Glenn

56e6a60039e0a5d8910392a4707f6f14LLLLLLLLLLLLLLLLLLLLLLLLLLLL