Getting started with Vmware Power CLI scripting

This week I got acquainted with Power cli scripting.Its is fun once we get started with it, and it is easy too..

 Power cli is a wonderful tool that you can use to create scripts for vsphere management. You can get started with it by installing power cli tool.Another easier method is to install power gui. For this you will need to install vi client and power cli as prereq .Once power gui is installed you need to enable the vim plugin from the file menu

You will need the help of both vmware power-cli command line reference as well as the windows powershell reference.

 Start with the basics . First run few commands on the power cli and understand how they works. Then you can put them together in a script with extension .ps1 . 

For eg try some basic commands like:

Get-VC : Connect to virtual center

eg: Get-VC

Get-Resourcepool : get details of resource pool of any location say host,cluster,datacenter

eg: Get-Resourcepool -Location clustername

If you want to store the value in a variable for further use in your script, you can do it as follows

$pools = Get-Resourcepool -Location mycluster

Here all the name of the resource pools in the cluster is stored in the variable $pools. Interesting thing to note is that if there are multiple values, it automatically gets stored as an array.

More posts coming up on power cli scripts :)


Popular Posts