#Clear screen
cls
# remove any lingering variables
Remove-Variable -Name * -Force -ErrorAction SilentlyContinue
#connect to Virtual Center Server
Connect-VIServer vCenter1
#get VMs
foreach($vm in (get-view -ViewType VirtualMachine))
{
foreach($rdm in $vm.Config.Hardware.Device)
{
if(($rdm.gettype()).Name -eq "VirtualDisk")
{
if(($rdm.Backing.CompatibilityMode -eq "physicalMode") -or ($rdm.Backing.CompatibilityMode -eq "virtualMode"))
{
$Details = "" | select VMName, VMDK, Mode
$Details.VMName = $vm.Name
$Details.VMDK = $rdm.Backing.FileName
$Details.Mode = $rdm.Backing.CompatibilityMode
$Details.PSTypeNames.Clear()
$Details
}
}
}
}
Disconnect-VIServer vCenter1 -Confirm:$false
No comments:
Post a Comment