Beginning of a beautiful friendship

My first PowerShell script. It retrieves the details of guest systems from a vSphere server.

$props = @('VMHostId', 'Id', 'MemoryMB', 'Name', 'Notes', 'UsedSpaceGB', 'PowerState')

"vmlist" | Out-File  -encoding utf8 vmlist.txt
 
$containers = Get-Cluster | sort

foreach($container in $containers){
	$hosts = Get-VM -Location $container.name 
	 foreach($hosta in $hosts){
		write-host $hosta.name   "cluster"  $container.name 
		$hosta.name + "  cluster  " +  $container.name  | out-file  -encoding utf8 -append vmlist.txt
		foreach($prop in $props){
				write-host $hosta.name   $prop  $hosta.$prop
				$hosta.name + "  " + $prop + "  " + $hosta.$prop | out-file -encoding utf8 -append vmlist.txt 
			}
		Get-Annotation $hosta.name | out-File  -encoding utf8 -append vmlist.txt
		}
}

Of course you’ll need the vSphere PowerCLI for this.

Cloud management for the poor.