Home > Blogs > VMware PowerCLI Blog > Monthly Archives: November 2011

Monthly Archives: November 2011

vCloud Director PowerCLI Cmdlets

Would you like to win access to the fantastic PowerCLI Course by Trainsignal ?

Would you like to help shape the future of PowerCLI ?image

Read on….

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.

 **Optional. Please note that we will only use your email to contact the winner, no spam will be sent and no record of this address will be kept for future reference.**

Please fill in the 4 question survey here

Any questions around this area can be posted in this community link: http://communities.vmware.com/thread/337330?tstart=0

VM Tools and Virtual Hardware Versions

Alan Renouf, Sr Technical Marketing Architect, VMware

After reading Kyle’s post on the ESXi Chronicles blog here (I didn’t know you could do that) I wanted to show how you could gather and also export the Tools and Virtual Hardware Version in PowerCLI, this also allows us to use one of my favorite cmdlets New-VIProperty, a great post on this cmdlet can be found here.

If we look at the  object which gets returned back when we use the Get-VM cmdlet you will see that there is a root property for the Name, PowerState, NumCPU and many many more, one of these is the Version, this shows the hardware version so its easy enough to grab each VM’s name and Hardware Version by using:

Get-VM | Select Name, Version

But 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

image

Of course we can choose which list of VMs to get this information for:

For a Datacenter: Get-Datacenter London | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

For a cluster: Get-Cluster Production | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

For a host: Get-VMHost Host1.mydomain.local | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

And we can also easily export this information into a csv file:

Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus | Export-Csv -NoTypeInformation -UseCulture -Path C:\Temp\VMHWandToolsInfo.csv

How do you use PowerCLI ?

How do you use PowerCLI ?

That was one of the questions I asked this year at both VMworld Las Vegas and also VMworld Copenhagen, there was some nice answers to this question, often people I meet are using PowerCLI in ways I never thought of, others don’t realize how powerful it actually is and how much time they can save.

This year at VMworld there was lots of great fun around PowerCLI, if you want to see how people use PowerCLI and see what the buzz was like at VMworld then please watch the below video.

If you have cool ways you are using PowerCLI make sure you add a comment to this post to tell everyone else !

 

vSphere Distributed Switch PowerCLI cmdlets

For a long time now when presenting at VMworld or user groups I have asked the question – What would you like to see from PowerCLI next ?  The standard answer I get at most of these is vSphere Distributed Switch (VDS) cmdlets !

Luc Dekens did a great job with his series of posts showing how you could create your own VDS advanced functions, these allow you to add the functions to your PowerCLI session and work with VDS, find them here and take a look, they are a great example of how you can expand PowerCLI to support areas not yet written.

So what’s new ?

VMware have now released some PowerCLI cmdlets as a fling which work with VDS and allow you to do most of the common VDS tasks in your vSphere environment.  Please note that this is a fling and therefore not officially supported by VMware, having said that we are definitely keen for you to download these and try them out – please make sure you leave feedback as this will help with future versions !

Requirements

  • Windows required XP, Windows Vista or Windows 7, Windows Server 2003, 2008
  • VMware PowerCLI 4.1.1 or later is needed

Continue reading

Have you seen PowerCLI’s “Credential Store” feature?

It just occurred to me that a very useful feature of PowerCLI never got the introduction it deserves. The feature is the Credential Store and as the name suggests its job is to store credentials. As a result:

  1. Credentials are kept securely (no need to hard code passwords along with scripts)
  2. You type less (no need to specify user and password to Connect-VIServer)

So, how does it work in practice?

Say I connect to my VC like this:

Connect-VIServer 192.168.10.10 –User Andrey –Password “my favorite password”

To use the credential store, I do the following:

New-VICredentialStoreItem -Host 192.168.10.10 -User "Andrey" -Password "my favorite password"

Now I can type just:

Connect-VIServer 192.168.10.10

When I don’t specify user and/or password, Connect-VIServer checks the credential store, finds my newly stored credential and uses it.

By default the credential store file is stored under the user profile directory. It is encrypted. If I got you interested, check “help *VICredentialStoreItem” for details.

 

Andrey Anastasov,

PowerCLI Architect

PowerCLI Lab at VMWorld 2011 – lab manual and scripts

It's been a very successful VMWorld this year, especially for PowerCLI – lots of sessions and a great lab. For the first time this year we had a scenario-based lab – migrating a vSphere 4 environment to vSphere 5. For those of you that were unable to attend the lab during the event – be sure to check the attached lab manual and scripts below. We hope to see you at the event next year!

Download PowerCLI lab manual 2011

Download Collect-v4-Configuration

Download Run-v5-setup