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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting VM information from Hyper-V 2012 via PowerShell
Posted in Windows Powershell, Windows Server | No Comment | 1,495 views | 18/06/2013 10:10

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

1
2
3
4
5
6
7
8
9
10
11
$VMs = Get-VM
foreach ($VM in $VMs)
{
	$VMName = $VM.Name
	$VMHostname = $VM.ComputerName
	$VMHostCluster = (Get-Cluster).Name
	$VMHardDisk = $VM.ConfigurationLocation
	$VMHardDiskLocation = $VMHardDisk.Split("\")[2]
	$Value = $VMName + "," + $VMHostname + "," + $VMHostCluster + "," + $VMHardDiskLocation
	Add-Content -Value $Value -Path "VMList.txt"
}

You need to run this script on all Hyper-V hosts.



Leave a Reply