search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting VM information from System Center Virtual Machine Manager 2012 via PowerShell
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 1,685 views | 17/06/2013 14:57

You can get your prod VMs list, Hyper-V hostname, clustername and csv paths like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
$VMs = Get-SCVirtualMachine | where {$_.HostGroupPath -like "All Hosts\*Prod*"}
foreach ($VM in $VMs)
{
	$VMName = $VM.Name
	$VMHostname = $VM.Hostname
	$VMHasPassthroughDisk = $VM.HasPassthroughDisk
	$VMHost = Get-SCVMHost $VMHostname
	$VMHostCluster = $VMHost.HostCluster
	$VMHardDisk = @($VM | Get-VirtualHardDisk)[0].Location
	$VMHardDiskLocation = $VMHardDisk.Split("\")[2]
	$Value = $VMName + "," + $VMHostname + "," + $VMHostCluster + "," + $VMHardDiskLocation
	Add-Content -Value $Value -Path "VMList.txt"
}

If you need to get all vms, just try “All Hosts\*” for all host groups.



Leave a Reply