Category Archives: VMware

QuickTip: Add VMware PowerCLI to PowerShell Console

Although officially the PowerCLI cmdlets are only supported by VMware when running the PowerCLI console it is possible to add the majority of the PowerCLI cmdlets by manually adding the VMware.VimAutomation.Core snapin in your current console:

Add-PSSnapin -Name VMware.VimAutomation.Core

This is particularly useful when running PowerCLI script from the task scheduler as the scripts can just be executed using PowerShell.

As suggested in the comments it is also possible to add all registered VMware PSSnapin’s by runing the following code:

Get-PSSnapin -Registered |
Where-Object {$_.Name -like 'vmware*'} | ForEach-Object {
    Add-PSSnapin -Name $_.Name
}

PowerCLI Sessions at VMworld 2013 San Francisco announced

The following PowerCLI sessions have been announced for VMworld San Francisco next month:

VAPP5473 – Automated Management of Tier-1 Applications on VMware
https://vmworld2013.activeevents.com/connect/sessionDetail.ww?SESSION_ID=5473
VSVC4944 – PowerCLI Best Practices – A Deep Dive
https://vmworld2013.activeevents.com/connect/sessionDetail.ww?SESSION_ID=4944
VSVC5931 – PowerCLI What’s New? Administrating with the CLI Was Never Easier
https://vmworld2013.activeevents.com/connect/sessionDetail.ww?SESSION_ID=5931

Head over to the VMWare blogs to read an summary blog post on the PowerCLI related sessions at VMworld:

http://blogs.vmware.com/vipowershell/2013/07/powercli-session-at-vmworld-2013-san-francisco.html

Gather VMHost information using vSphere PowerCLI

To gather some basic information the Get-VMHost Cmdlet offers a wealth of information. Most basic information is easily accessible using the following command:

Get-VMHost

For the purpose of this article, we are looking for some identifying information regarding our ESX hosts. The attributes that we are after are the following:

  • Hostname
  • ESX Version and Build number
  • vSphere Uid
  • Hardware Uuid
  • The parent folder/cluster or data center which contains the ESX hot

Since these fields are scattered around, the following piece of code can be used to gather this info:

Get-VMHost | ForEach-Object {
    $_.Name
    $_.ExtensionData.Summary.Config.Product.FullName
    $_.Uid
    $_.ExtensionData.Hardware.SystemInfo.Uuid
    $_.Parent.Name
}

It does take a bit of effort to locate the data in this fashion, but once found it can make a considerable difference. For example if I wanted to gather the host name of the ESX host, the cluster in which it is located and the datacenter in which the cluster is stored, the following commands could be executed:

Get-VMHost Server01* | Select-Object -ExpandProperty Name | Tee-Object -Variable Server
Get-Cluster -VMHost $Server | Select-Object -ExpandProperty Name
Get-DataCenter -VMHost $Server | Select-Object -ExpandProperty Name

This can be shortened to a single command with a ForEach-Object statement:

Get-VMHost Server01* | ForEach-Object{
    $_.Name
    $_.Parent.Name
    $_.Parent.ParentFolder.Parent.Name
}

This has the advantage that only a single Cmdlet is used to retrieve the data from vCenter which makes the code easier to write and faster to execute, especially in large environments.

VMware Certified Professional on vSphere 5

As of last week I have achieved the VMWare Certified Professional on vSphere 5 certification. After a training course last month, I have spent most of my spare time studying to prepare for the examination.

For the aspiring VCPs I would like to share the resources I have used to study for this exam. My starting point was both the book and study guide provided by VMWare, the guide can be found here:

http://mylearn.vmware.com/mgrReg/plan.cfm?plan=12457

Furthermore I found vReference.com to be a good resource with a wealth of information in order to properly prepare for the exam. I specifically used the vSphere v5 Notes to assess my own knowledge and whenever I found an unfamiliar topic I would know what to focus on next. With about 50 pages it is quite extensive and it can be found here:

http://www.vreference.com/vsphere-5-notes/

Also there are many virtualization and VMware blogs that cover a wide range of topics. The blogs I frequented the most and which contained the most relevant information for my preparation has been yellow-bricks.com. I would highly recommend this site if you are planning to prepare for the exam or to read up on new developments in the VMware world.

http://www.yellow-bricks.com