Tag Archives: PowerShell

Calculate vSphere 5 Licenses with Powershell (UPDATED)

VMware has announced the next generation of vSphere yesterday. Besides lots of new features, vSphere 5 also comes with a new licensing structure. For every licensed physical CPU, you get a certain amount of vRAM, which you will be able to allocate to virtual machine. Only the running VM’s will count towards your license limit.
Curious how the vSphere 5 licensing model will impact your license cost? Want to know how many vSphere 5 liceses you will need? The following script calculates exactly how many licenses you need for the different editions and how much overhead you will have left.

UPDATE 04-AUG-2011: vmware has increased vRAM entitlements for all editions of vSphere 5! I have updated the script (shown below and the attached script). The screenshot is still the old one. Please read the new Licensing PDF here for all the details.

NOTE: Please note that I add up all your pCpu’s, ignoring current license types. I also add up all your current vRAM usage (RAM assigned to powered on VM’s). I then show you different scenarios if you purchase license type x for ALL your pCpu’s. If your environment consists of a mix of vSphere editions, check out Alan Renouf’s script to analyse your environment.


Continue reading

»crosslinked«

Remove vmware memory limits with Powershell

Using Memory Limits in vmware vSphere can cause severe performance issues. The guest operating system assumes it can use all of the allocated memory, but vSphere will make sure the vm cannot use more than the memory limit. It does this by inflating a memory balloon using the balloon driver included with the vmware tools. The performance chart in the vSphere Client will show the virtual machine is ballooning. I never recommend using memory limits in vmware.
The following script will remove all memory limits in your vSphere infrastructure, preventing the problems described above. Continue reading

Find LUN ID’s in VMware with Powershell

Determining the LUN ID for a specific LUN in your VMware Infrastructure used to be simple. It was listed as one of the properties of the datastore you selected in the VI Client. Nowadays, more often than not, I dont see the LUN ID in the vSphere Client. Instead, I see some sort of identifier like “EMC Fibre Channel Disk (sym.12673548127)”.
Even more unfortunate is the fact that all my scripts show the same identifier, where they used to show the LUN ID. So I decided to create a script that can translate the identifier (sometimes referred to as Canonical Name) back to a LUN ID.
By the way: in the vSphere Client, you can still find the LUN ID by opening the datastore’s properties window and clicking Manage Paths. Or you could write down the canonical name, switch to the devices view and look up the device there. That is essentially what my script does for you.
Here we go:
Continue reading

Fix DCOM Event 10005 with Powershell

Do you get these events in your system log?

The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. attempting to start the service ntmssvc with arguments “-Service” in order to run the server:
{D61A27C6-8F53-11D0-BFA0-00A024151983}

Symantec explains this is caused by disabling the Removable Storage Manager and provides a solution.

Removing those registry keys on a bunch of servers manually is a pain. Modifying DCOM settings even more so. So I explored fixing this with Powershell.

Continue reading

Set VMware Snapshot Location with Powershell

Snapshots are m*th3rfcukers. If you’re not careful, they will mass-murder your vms. Yet they allow you to time-travel! You want to use them, but how to prevent a massacre? Here’s how: relocate the delta files.

When you create a snapshot, the current state of the vm is preserved by leaving the disk files alone. All changes since the moment of creating the snapshot are written to delta files. The delta files are stored in the vm’s working directory. The working directory is – by default – the location where the vmx and other config files reside. If that datastore runs out of free space – especially if it also contains disk files – you’re in a bit of a kerfuffle. Vms not booting or being frozen as if they stared into Medusa’s reptoid eyes.

So you can do two things: reserve overhead in your datastores and stay afraid some overactive snapshot might destroy your environment, or set the working directory of your vms to some big-ass datastore you don’t use for anything else and let the snapshots enjoy themselves. If they fill up the datastore, they only kill all vms with snapshots, not the rest.

But how, you ask? You can edit the vmx files of you vms manually - which requires your vms to be powered down – and add the line: workingDir = “/vmfs/volumes/<insanely long guid you need to somehow find>/”

Or, you run my script and change the working location on the fly:

Continue reading

Create a vSwitch Port Overview with Powershell

WARNING: VMware vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in this KB article.
The solution to this problem is to create vSwitches with sufficient ports, obviously. Do you want to know how many ports are currently being used on every vSwitch in your environment? vSphere PowerCLI to the rescue! Try the following script:

Continue reading