I just noticed this awesome work by LucD. He developed two scripts which can import and export DRS affinity rules. Especially in large environments or environments that have multiple affinity rules this is an excellent solution. Take a look at the link above for more details. Luc posted the script half way down the topic in text but also added a modified version at the bottom. The VI Toolkit at it’s best… or should we call it PowerCLI these days?
Scripting
VMware vSphere Health Check Report v1.0
I already blogged about this awesome healthcheck script by William Lam a couple of times and it just has been updated to version 1.0. The following details have been added to the already extensive list:
- New New licensing format/summary
- New EVC Enabled information
- New Cluster VM monitoring
- New Cluster Host monitoring
- New # of VMotions within a cluster
- New Datastore uncommitted info
- New CPU power management info
- New VM info (FT, Record/Replay, Clean Poweroff)
- New Host IPv6, FT, SSL Thumbprint
- New Host Profiles
- New vApp information
- New Distributed vSwitch information
Check the detailed output example William uploaded recently.
SRM: Running a script from a Recovery Plan
I got a question today from one of my customers on how to run a script from an SRM Recovery Plan. They tried everything but never got it working. It’s fairly easy, although you would need to take a couple of things in consideration. And reading the SRM Admin Guide page 52 and 53 wouldn’t harm you as well. But then again we’re talking technical people here, who reads the manual? (Besides Mike Laverick aka Mr RTFM of course. Mike, btw, also recently released the third chapter of his SRM book for free, which is most definitely worth reading!!)
I guess the most important things to remember if you want to run commands/batch files from SRM are:
- SRM can only execute .exe or .com files, if you need to run a batch file do the following:
c:\windows\system32\cmd.exe /c c:\yellow-bricks.bat
- Scripts must reside on the host where the SRM server is installed.
- SRM callouts to batch files or commands run as the local administrator of the SRM server host, and not as the user logged into the VI Client.
- A recovery terminates if a command or script exits with a non‐zero status.
- If the script call out takes longer than 300 seconds to complete it will be terminated. You can increase this by changing/adding the following line in vmware-dr.xml with the desired value:
<calloutCommandLineTimeout>600</calloutCommandLineTimeout>
Update: VMware Health Check Report 0.94
William Lam posted an update of his Health Check script on the VMTN Communities. I’ve been using this script extensively at several customer sites together with VIMA. Here are the release notes:
03-24-2009 – v0.9.4
Fixes:
-There was a bug reported by Duncan Epping and others regarding hosts that were appearing in the wrong cluster with respect to the portgroup listings, this should be fixed.
Enhancements:
-Detail Hardware Health sensor readings provided by CIM
-CDP Summary (individual cdp.pl available)
Speed up your powershell scripts
On the VI Toolkit blog there’s a great article for people like me. They explain how to speed up your scripts. I’m no powershell guru, and these kind of articles are more than welcome to boost my scripting skills.
In short, it comes down to these three tips:
- Try to load as many objects as possible into arrays beforehand. Once you’ve got them loaded you can use them as arguments to multiple calls without having to resort to potentially expensive lookups every time.
- Just like in sample 1 above, when you’ve loaded objects, use the objects directly rather than using their names. This is usually not hard as our cmdlets are designed to take object first-and-foremost, and names are supported just as a convenience.
- If you absolutely need to load a single VM object by name, load it using the Get-VMFast function below. While this approach can certainly help, it’s not nearly as good as using the other two techniques mentioned above.
Head over to the VI Toolkit blog and start reading.