VMware 通过PowerCLI列出所有RDM磁盘在主机和虚拟机

准备一个圣圣迁移我需要列出原设备映射所有虚拟机,我发现一个很好的脚本在Pastebin(我这你的脚本,请评论获得学分),脚本:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$report = @()
$vms = Get -VM | Get -View
foreach ( $vm in $vms ){
foreach ( $dev in $vm .Config.Hardware.Device){
if(( $dev .gettype()).Name -eq "VirtualDisk" ){
if(( $dev .Backing.CompatibilityMode -eq "physicalMode" ) -or
( $dev .Backing.CompatibilityMode -eq "virtualMode" )){
$row = "" | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize, HDDisplayName
$row .VMName = $vm .Name
$esx = Get -View $vm .Runtime.Host
$row .VMHost = ( $esx ).Name
$row .HDDeviceName = $dev .Backing.DeviceName
$row .HDFileName = $dev .Backing.FileName
$row .HDMode = $dev .Backing.CompatibilityMode
$row .HDSize = $dev .CapacityInKB
$row .HDDisplayName = ( $esx .Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev .Backing.LunUuid}).DisplayName
$report += $row
}
}
}
}
$report

image

Ps. the script can take a while to list…


你可能感兴趣的:(虚拟机,report,eq)