RSS

PowerCLI count VMs for each host in each cluster

14 Feb

Need to do a quick inventory of our environment and needed to get a list of clusters, ESX host and VM count per host.

Updated: Ensure that you have a stored credentials first

$cred = get-credential
Get-content .\vc.txt | % {
$vc=$_ ; connect-viserver $vc -credential $cred;
get-vmhost |
select-object name, parent, @{Name="VMCount";
Expression = {(get-vm -location $_ | measure-object).count }} |
export-csv .\$vc.txt ;
disconnect-viserver $vc –force –confirm:$false }

 

Advertisements
 
Leave a comment

Posted by on February 14, 2014 in powershell, Scripts, vmware

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: