Bulk create vSwitch networks

I blogged a bit about this in the Consolidating datacenters post. As part of moving a customers VM’s in to our datacenter, the network and storage was streched and host deployed in our datacenter was presented to the customeres vCenter, so that it was a simple (s)vMotion, that was all that was needed to move the VM’s from customer site to our datacenter. Simple, fast and effective.

All this was only possible because the customer still used the standard vSwitch - As our datacenter uses the distributed virtual switch, I created this script in order to stadalize how network was created on each host presented to the customer vCenter - This insures that the hosts are configured correctly and saves me a lot of clicks with the mouse. The script currently doesn’t set which vmkernel port is used for vMotion, the reason for that is that, I had the need for multiple vMotion port for the different parts of the customer site, so is was much easier, to just change that manually. If you only need one vMotion/vmkernel port you append the following to the “Set-VirtualPortGroup” line in the vmkernel port section of the script.

[]

Reset VM reservations and limits

I was moving a customers VM’s from their site via vMotion into our datacenter, and one of the problems you can run into is with reservations and limits. There may have been valid reasons for having limit and reservations, but they can also be the root of performance problems. As this was not the case with this customer, I created the one liner below in order to remove the reservation and limits.

[]

vCops Forced password change

Short after vCops 5.8 was released I upgraded, all went smooth. But then the other day, I had to restart the appliance, after waiting a while and I was still not able to login to the web gui. I open up a console to the two VMs, only to see the both VMs were stuck at boot waiting for a password change. So I typed in the old password and a new one and shortly after vCops was up and running again.

[]

CIM error

I was trying get some hardware info via CIM, the other day and ran into this error message:

Get-CimInstance : The response that the WS-Management service computed exceed the internal limit for envelope size.

At line:4 char:12
+ $Logical = Get-CimInstance -CimSession $Session -ClassName CIM_EnabledLogicalEle ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : LimitsExceeded: (root\cimv2:CIM_EnabledLogicalElement:String) [Get-CimInstance], CimExce
ption
+ FullyQualifiedErrorId : HRESULT 0x80338049,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
+ PSComputerName : hostname

After googling the error i found a lot of site pointing to this command -

winrm set winrm/config @{MaxEnvelopeSizekb="1024"}

which needs to be run as admin. Only problem it doesn’t work on windows 7/2008+… As it turns out, it was for windows xp/2003 - So I starting looking for the same command for windows 7/2008+ and guess what I found one. Once again this needs to be run as admin in powershell this size can be changed as needed on some HP G7 blade 1024 was enough, but when I tried to do the same command on a G8 blade it once again failed with the above error message, so I had to increase the size once more. Well you need to find your own setting, but the below is a good starting point.

[]

Batch rename of VMs

The other day a consultant came by my desk. He had a problem, the 400 VMs we just move from the customer site in to our datacenter; The backup jobs were failing for most of the VMs.

He had looked into it and it turns out that Symantec Netbackup, which is what is used, is case sensitive and the VM names were all a mix of low, high and low and high cases. So the backup team had to recreate the backup jobs, but before they did that, the consultant asked if it wasn’t possible to rename all of the VMs so the names became all lower case.

[]

Unmount datastore

Was at VMUGDK the other day listen to Paudie O’Riordan to one of his great session on storage troubleshooting - He was talking about how to remove datastores safely and this script that I’ve created for our storage team earlier this year came to mind.

The script reli on William Lam’s powershell module which can be found here http://blogs.vmware.com/vsphere/2012/01/automating-datastore-storage-device-detachment-in-vsphere-5.html

The script has four options; list, unmount detach and all - The first three is self explanatory and the latter simply does all three, first it unmounts the datastore, then it detaches the datastore and lastly it list the datastore to verify it status.

[]