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

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to get list of virtual machines with passthrough disks via PowerShell
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | 4 Comments | 4,951 views | 22/05/2013 16:59

In this sample script, I use SCVMM 2012 to get virtual machine list.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$VMInfo = Get-VM $Server
	$VMHost = $VMInfo.VMHost
	$VMHostName = $VMHost.Name
	$VMHostGroup = $VMHost.VMHostGroup
 
	if ($VMInfo.PassThroughDisks)
	{
		$PassThroughDisk = "True"
	}
	else
	{
		$PassThroughDisk = "False"
	}
 
	if ($VMHostGroup -like "All Hosts\*")
	{
		Add-Content -Value $Server -Path C:\Servers.txt
		Add-Content -Value $VMHostName -Path C:\VMHosts.txt
		Add-Content -Value $PassThroughDisk -Path C:\PassThroughDisks.txt
	}
}

Also you can filter specific Host Groups like in this sample.


Comments (4)

Mih

June 17th, 2014
15:53:26

I run above script successfully but i did not get any thing in vmhost.txt and passthroughdisks.txt may i am missing so kindly help me for the same.


admin

June 17th, 2014
16:10:31

Hi Mih,

Maybe you don’t have enough permission to write into C:\. You write your Hyper-V hosts into C:\Servers.txt file, right?

Yusuf.


Mih

June 24th, 2014
07:50:38

Thanks for your reply ,what exactly need to change in your script ?
Servers.txt ?VNHost.txt ?Passthrough.txt ? etc. kindly explain more.

Tahnks,
MIH


admin

June 24th, 2014
09:34:38

You need to change Servers.txt file. You should add your Hyper-V host list in it.

Yusuf.



Leave a Reply