Rob Daniels at ClearPath Solutions Group has an interesting post on disabling a view pool for VMware. He points out that there isn’t currently a PowerCLI command to do it, but came up with a PowerShell solution anyway.
Have you ever wanted to disable a VDI pool from the command line, but couldn’t find the right command for the job? As simple as it may seem to do, VMware has yet to equip the PowerCLI Snap-in with a “disable-pool” commandlet. Some may try to accommodate this by simply removing pool entitlements, but you can be faced with the following error:
Remove-PoolEntitlement : PowershellService::RemovePoolEntitlement FAILED,
error=User with sid has an active VDI Session on Pool . Entitlement cannot be
removed until this session is terminated.
This error is the result of an active desktop session attached to the entitlement being removed, or worse, anywhere within the VDI system as this is a global property. What this means is that if a user has an entitlement to more than one pool, this command may fail every time. As a work-around, there is a value within the local ADAM database on the View broker server. It is a Boolean value with the name “pae-Disabled” and can be found in the vdi.vmware.int\Applications\ attribute of the local LDAP. Below is an example of how this value can be toggled from a script:
(read more and get script)
3 months ago - link
Jason Hofferle has a nice post that discusses using PowerShell implicit remoting to take advantage VMware’s View cmdlets when you aren’t on the connection server.
One of the differences between the VMware View cmdlets and PowerCLI is that the View cmdlets can only be run on the connection server itself. Despite the lack of a Connect-VIServer equivalent, with PowerShell Implicit Remoting it’s still possible to use these cmdlets from a workstation.
First, PowerShell Remoting needs to be enabled on the Connection Server. There are several ways to configure remoting, but in a domain environment I like to turn it on with group policy. Enabling the automatic configuration of listeners is usually all the configuration necessary to enable remoting on a domain server, but lots of information is available for different situations.
(read more and get sample code)
3 months ago - link
Jonathan Medd has posted another useful PowerShell/PowerCLI script. This time he is looking at Cluster storage capacity.
I recently needed to provide a high level capacity overview per VMware cluster looking at some metrics of interest that were being used as a guide to the capacity state of a cluster. Note: these are by no means definitive or the ones you should be using in your environment, but for these purposes they met the requirements. The metrics I looked at per cluster were the ratio of vCPUs to pCPUs, the amount of Effective, Allocated and average Active Memory and the amount of Free Diskspace.
(read more and download script)
As is usually the case, it would be very straight forward to convert this script to a PowerWF workflow or a PowerVI script so that you can run it from your vSphere client.
4 months ago - link
Did you know that PowerVI includes a PowerShell script that lets you change the root password on multiple ESX host at one time. This is useful if you have a policy to change the passwords regularly, but want to keep the password the same across all hosts.
To change the password -
- Make sure PowerVI is installed.
- Open the vSphere client and connect to your vCenter
- Select all of the ESX Hosts that need to have their root password changed
- Right click and select “Set Host Root Password”

- PowerVI will launch a dialog that lets you specify the old password and set the new password.

- PowerVI will show you the progress as it changes the password for each of the selected hosts.
5 months ago - link
Don Jones has a short article on PowerShell cmdlet name conflicts. The article discusses what happens if multiple PowerShell modules have cmdlets with the same name, such as Get-VM which could show up in a HyperV and VMware/vSphere/PowerCLI module. It is a short article, but worth a quick read to understand how PowerShell handles these conflicts.
5 months ago - link
VMware is in the process of extending PowerCLI capabilities to automate vCloud Director, and they want your feedback (assuming you currently use PowerCLI).
As announced at VMworld 2011, we are currently in the process of extending the PowerCLI capabilities to automate vCloud Director (vCD) configuration, as part of this we would like to focus the users of PowerCLI and vCloud Director and allow you to have your say.
To do this we have put together 4 simple questions to get your feedback.
Please select the option that best fits your desired user experience for each of the questions.
To thank you for filling in this survey, we will select one of you at random to take the PowerCLI training course online on the TrainSignal website.
(read more)
6 months ago - link
Alan Renouf has a new blog post up that takes advantage of the New-VIProperty cmdlet to add the VMware tools version to the get-vm cmdlet. you may recall that Luc Dekens had a rather extensive post a while back that talked about many cool things you could do using the New-VIProperty cmdlet.
Here’s Alan’s use case…
If we look at the object which gets returned back when we use the Get-VM cmdlet you will see […] the returned object doesn’t have a root property for ToolsVersion or ToolsVersionStatus, for this we need to delve into the ExtensionData property and have a look around, once we have found the information it is fairly easy to add these to our object using the New-VIProperty cmdlet as below:
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine `
-ValueFromExtensionProperty ‘Config.tools.ToolsVersion’ `
-Force
New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine `
-ValueFromExtensionProperty ‘Guest.ToolsVersionStatus’ `
-Force
Now we have added these as a new property to our object (actually they are PowerShell Code Properties), we can use our old friend Get-VM to retrieve the information easily:
Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus
(read more)
It looks like Alan’s use case looks like it may already be covered, but I figured I would post the information anyway.
6 months ago - link
Network stats must be the PowerShell topic of choice this week. The following all showed up in my RSS feed in the past few days:
- From Jeffery Hicks:
Turning IPConfig DNSCache into PowerShell - Lately I’ve been writing about techniques to turn command line tools into PowerShell tools. Although I suppose the more accurate description is turning command line output into PowerShell pipelined output. The goal is to run a command line tool and write objects to the PowerShell pipeline so I can do other operations with them. Today I have another example that takes the DNS cache from IPConfig and turns it into a collection of PowerShell objects.
- From Niklas:
PowerCLI to the rescue, how to check all VMs for Network card type - I got a question what network card some VMs had in a datacenter, as a best practice you should use VMXNET 3 where it is possible because it gives the best performance. So i wrote this very simple [PowerShell/PowerCLI] script in a few lines that do a csv export of all VMs and what kind of NIC they have, of course one could extend it with OS and stuff but that will have to be next time cause my schedule is kind of tight.
- From Luc Dekens (in answer to vite@1):
PowerCLI script that lists every IP within vCenter - I found a script that lists all VM’s IPs in vCenter and a command that list vMkernel ports adapter’s IPs. Is there a way that I can put these two together in a script? LucD - the following will give you the Name ,[IP Address] and the MAC
6 months ago - link
I was writing a new PowerShell script for PowerVI the other day to monitor free drive space on my virtual machines. Using PowerCLI, it was very easy to get the basic storage information for my VMs - UsedSpaceGB, ProvisionedSpaceGB, but I was surprised that Free Space and Percent Used were not immediately available.
No problem, PowerShell makes it pretty easy for me to add my own calculated columns to my results.
Select-Object -Property Name, Host, NumCpu, MemoryMB, PowerState, UsedSpaceGB, ProvisionedSpaceGB, @{Name=”PercentUsed”;Expression={[System.Math]::Round(100 * $_.UsedSpaceGB / $_.ProvisionedSpaceGB, 2)}}, @{Name=”FreeGB”;Expression={ [System.Math]::Round($_.ProvisionedSpaceGB - $_.UsedSpaceGB , 2)}}
You can see that I added one column named PercentUsed, and a second column called FreeGB. The syntax is basically…
@{Name=”ColumnName”;Expression={your-expression}}
In this case, the Expression uses the $_ syntax to perform a calculation on the current object. PowerShell doesn’t have its own math cmdlets, and instead relies on the [System.Math] methods. You can see more examples here.
BTW - the complete script is included with the latest version of PowerVI.
6 months ago - link
:::