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...
-
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...
-
Have you tried to set up or change a root's password for an ESXi host and got the following error message: Weak...
-
If you just install VMware Converter and start running it with it’s default configuration, I’m sure you will be successfully. But, the...
-
I've been working on a project to upgrade a vSphere 5.0 environment to vSphere 5.5. One of my client’s concerns was about what Guest...
-
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...
-
Day two of a VMware NSX implementation and I was surrounded by angry network guys asking me: “ What have you done ? ” As scare as...
-
Do you know the LUNs on your environment might have different versions ? Yeah, that’s true!! To check tha LUN version, on the configuratio...
-
A friend of mine had a challenge, identify which VM belongs to which owner !!! The reason for that is simple. Since here is a service p...
-
Recently I’ve worked with one of my customers to scale-out their vRealize Automation (vRA) environment enabling High...
1 comment:
Post a Comment