I realized that every post about PowerCli I write I need to give the same instructions: Install, configure, etc…
So, I’m creating this post with the basics of PowerCli and in the future I will always make reference to this post.
Let’s get started:
Make sure you have PowerShell installed (newer O.S. already have it, if you don’t have it go to Microsoft web page download and install it.)
Then you need to install PowerCLI, download it here. (the installation is pretty much the same…Next..Next..Finish)
Now, that it’s installed, you just need to launch, there should be a shortcut on your desktop or through the Programs Menu under VMware
First thing you need is to connect on your Virtual Center.
- Run: Connect-VIServer –Server “your_VC”
Then you can place all the command and scripts
Exporting the results:
To export the results you can:
1. after the command add “ > file”
ex: Get-VM > c:\temp\result.txt
2. export to a csv file. After the command add “ | Export-CSV your file”
ex: Get-VM | Export-CSV c:\temp\result.csv
Working with batch files
PowerCli can also work with batch files, so you can create scripts and run them against just some specific serves.
- create a txt file with one host per line (ex: c:\temp\servers.txt)
Then you can read this for the source of hosts:
Option 1:
Reading the file to a variable
- Run: $host = Get-Content c:\temp\servers.txt
Running the command against the variable
- Run: Get-VM $host
Option 2:
Reading the hosts direct from file
Get-Content c:\temp\servers.txt | foreach { Get-VM $_ }
Here you go, now you are ready to play with PowerCli, the basic syntax is there, you just need to change the commands you need to run and adjust any additional parameter you might want.
See you next
Friday, November 5, 2010
Who am I

- Eduardo Meirelles da Rocha
- I’m an IT specialist with over 15 years of experience, working from IT infrastructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Consulting Architect, helping customers to embrace the Cloud Era and make them successfully on their journey. Despite the fact I'm a VMware employee these postings reflect my own opinion and do not represents VMware's position, strategies or opinions. Reach me at @dumeirell
Most Viewed Posts
-
vRealize Automation 7.1 brings several new features and functionalities, while the community is covering the fanciest...
-
VMware recently announced the end of availability of it’s billing product, vCenter Chargeback Manager , but what that means ? Fir...
-
There's this big buzz since VMworld last year, where the partnership between VMware and Amazon has been anno...
-
This is post two of protecting your Virtual Container Host (VCH), if you did not check post one , I really encourage you to check it out b...
-
Have you tried to set up or change a root's password for an ESXi host and got the following error message: Weak...
-
I have to admit since I started playing with PowerCLI I’ve been enjoying it more and more. A few weeks ago I needed to delete 50 VMs from t...
-
During the past few weeks, my NSX partner in crime, the Sr. Consultant Anderson Duboc and I have been working on a NSX Reference Poster...
-
If you just install VMware Converter and start running it with it’s default configuration, I’m sure you will be successfully. But, the...
-
Do you know the LUNs on your environment might have different versions ? Yeah, that’s true!! To check tha LUN version, on the configuratio...
-
I've been playing with Tanzu Kubernetes Cluster (TKC) on vSphere with Tanzu since vSphere 7.0 GA, recently, to be honest, have bee...
1 comment:
Post a Comment