Emptying a VMFS datastore with PowerCLI

Well, once again I hacked at the Powershell/PowerCLI the other day. Since we don’t yet have a Enterprise Plus license at work (which would support Datastore Maintaince and Storage DRS), I needed a way to empty one datastore and move all the content into another one, while enabling Thin-Provisioning.

So I googled for a bit, and actually found a few hints … So without further yada-yada, here’s the script I came up with:

Initially I have something different, which was a bit shorter (based on Brian‘s work), but it had a huge downside: If you have vRDMs (like I do), it converts every damn vRDM into a VMDK, so make sure you only run this script on a datastore on VMs that either have only pRDMs or VMs with only VMDKs.

Doing TSM’s job on Windows Server 2008

Ran into another weird problem the other day … Had a few Windows boxens running out of space. Why ? Well, because TSM includes a System-State backup when creating the daily incremental. Now, apparently (as stated by the IBM support) it isn’t TSM’s job to keep track of the VSS snapshots but rather Windows’. Now by default, if you don’t click on the VSS properties of a Windows drive, there is no limit on the volume. Thus, VSS is slowly eating up all your space.

That isn’t the worst of it, but when you want to delete it all … With Windows 2003 you would just this:

However, as with everything Microsoft, Windows 2008 R2 does it a little bit different. As a matter of fact, it won’t allow you to delete application triggered snapshots (as you can see in the example below), so you’re basically shit-out-of-luck.

Well, not really … diskshadow to the rescue. Simply running diskshadow with a simple script like this:

Just for clarification this isn’t my own work, it was someone elses.

Empty Port SSL after ADAM installation

I’ve been meaning to post this, but never actually got around to doing that. When installing vCenter 5.0, an instance of ADAM is installed, which stores all the configration data for Linked Mode.

It basically boils down to running this script and rebooting the box:

This is no new invention of myself, just writing it down for myself from here or here.

Rebooting a virtual machine via Task scheduler

Since the Scheduled Tasks in vCenter ain’t exportable, I went ahead and wrote a rather simple script, which lets me do this in Windows own Task Scheduler. What this script does, is initiate a graceful shutdown and if the VM isn’t shutdown within 60 seconds (12 * 5 seconds) it simply powers the VM off and immediately after that powers it back on.

Before this implementation in PowerCLI, I needed three tasks for each VM that was to be scheduled. And when migrating vCenters (and I usually do an empty install) vCenter’s scheduled tasks are not exportable, thus you need to re-create the tasks on the new vCenter by yourself again, which for more than four virtual machines is really a pain in the ass …

Update: well, found an error that caused shit not to work … Basically Stop-VM also needs the object for $VMname, otherwise the whole point of waiting for the VM to be stopped is kinda moot (seeing as Stop-VM never stops obsessing about not having a Get-VM object or a VM name to work with).

Reoccurring memory limits in vCenter

We recently had, after we migrated from vSphere 4 to vSphere 5, a memory limit in size of the configured memory on each and every VM. Since memory limits on VM level pretty much destroy performance, I went ahead an wrote this simple script to remove all memory limits on all VMs that don’t have “Unlimited” configured:

This script is basically what the guy over at get-admin.com did, just only for memory limits.

Been a while

Well, it’s been a while since I last blogged about anything. I’ve been real busy with work with the move from vSphere 4 to vSphere 5 (well planning takes a while …), reorganizing our vSphere Clusters/Farms, a lot of PowerCLI voodoo (some of it, I’m gonna post), the usual Windows honky-donky (Windows group policy for certain stuff).

Besides that, you know, I have some kind of personal life. That basically took all of my free time. So I’m gonna try to write some posts up in the next few weeks, with some PowerCLI scripts mostly, some Shell scripts for SVC-automation, as well as some NetApp foo, guess we’ll see.