VMware vSphere PowerCLI

Today is the first day I’m starting using VMware vSphere PowerCLI and I’ll post any script I’m writing during my study, I hope they become useful (some day).

Last night we have power outage and because I’m not using UPS at home for my lab, both of my systems powered off.
Today I have powered on them (ESXi 4.1 host and storage-management server)
By default my DC would be on as I’m set it to, but all other VMs not and this mean there’s would be no vCenter as well.
I decided to use PowerCLI for powering on the vc (vCenter) virtual machine, this procedure is very simple:
1. open the PowerCLI (it’s obvious)
2. connect to your host (here I got VMware vSphere Hypervisor 4.1)
* I’ll explain a little latter why I’m mentioning the Version
3. list all VMs or checking state of specific VM
4. power on the specific VM

Here is the screenshots and commands I used to power on my VM:
1. Opened the VMware vSphere PowerCLI

  1. Connecting to the host use following command:
    Connect-VIServer [-Server] <string[]> [-Port ] [-Protocol ] [-Credential ] [-User ] [-Password ] [-Session ] []

    here what I have used:


  2. Listing available VMs and specific VM (here is vc) using following command:

    Get-VM [-Datastore <Datastore[]>] [-Location <vicontainer[]>] [[-Name] <string[]>] [-Id <string[]>] [-NoRecursion] [-Server <viserver[]>] []

    And I use it like this:

    Get-VM vc

  3. Trying to power on VM with following command:

    Start-VM [-RunAsync] [-VM] <VirtualMachine[]> [-Server <viserver[]>] [-WhatIf] [-Confirm] []

    And I use it like this:

    Start-VM -VM (Get-VM -Name "vc") -Confirm

Well, as you can see it ended with error and the power on process failed.
Lets check the following lines which printed in red:

Start-VM : 10/13/2010 10:30:51 PM Start-VM 52c9c082-22a9-8efe-92d2-cede5a452eb fault.RestrictedVersion.summary
At line:1 char:9
+ start-vm <<<< -VM (Get-VM -Name "vc") -Confirm
+ CategoryInfo : NotSpecified: (:) [Start-VM], SecurityErrorException
+ FullyQualifiedErrorId : Client20_MoServiceImpl_Invoke_ViError,VMware.VimAutomation.Commands.StartVM

As you can see there is “fault.RestrictedVersion.summary” in the first line which means the license which is used by the host is not enough for doing the requested process.
The same error would be generated if users wants to configure the SNMP on their VMware vSphere Hypervisor using VMware vSphere CLI (vCLI).

  1. Checking the license on the host

  2. So, I changed the license

  3. Running the same command again

  4. After changing the license and powered on the VM, I have changed the license back to the free version (Hypervisor) and the following screenshot showing the license and VM state together.

It seems users who wants to use the VMware vSphere PowerCLI should use trial licensed hosts or buy the license for the hosts.

It's your kindness to leave a reply/feedback