HI,
In my first post about "Getting Started with VMware Vshpere PowerCLI" i already showed how to connect with VMware server.
Our today's task is simple. you get the list of all Virtual machines, and then we search for all "Powered ON" machines and after that all "Power off" machines.
Nothing complicated here. this is just a simple task and again the basic usage of Powershell is applies here. and we have some good "best friend " cmdlets those always with us. these cmdlets are "where-Object", "Select-Object".
Let's Start
Connect to your VMware server first using Connect-VIServer cmdlet. Once you successfully connected.
Run the Get-VM cmdlet.
That will show you the list of all Virtual machines including their "Power State"
If you want to see all the properties of Virtual Machines, run the below cmdlet.
Get-VM | Format-List *
Now you can see that we have detailed information about virtual machines.
And in case you want to know about a single Virtual Machine , use Get-Vm and -Name of the machine and then Piped it to fl *
Get-Vm -Name "Dummy-Windows7" | fl *
As i mentioned in the starting that our original target is to find the list of all Up and Running Virtual machines. To achieve that we can use Where-Object and show that Virtual machines whose status is equal to "Powered ON".
Get-vm | where { $_.PowerState -eq "PoweredOn"}
Thanks for reading.
Thanks!
Aman Dhally
ReplyDeleteI am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself. I hope this will help many readers who are in need of this vital piece of information. Thanks for sharing & keep your blog updated.
Salesforce training in Chennai|Fita Chennai Reviews
ReplyDeleteGreat thoughts you got there, believe I may possibly try just some of it throughout my daily life.
Modular Workstations Chennai