$DiskInfo= @()
foreach ($VMview in Get-VM server_name| Get-View){
foreach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "SCSI Controller"})) {
foreach ($VirtualDiskDevice in ($VMView.Config.Hardware.Device | where {$_.ControllerKey -eq $VirtualSCSIController.Key})) {
$VirtualDisk = "" | Select VMname, SCSIController, ControllerType, DiskName, SCSI_ID, DeviceName, DiskFile, DiskSize
$VirtualDisk.VMname = $VMview.Name
$VirtualDisk.SCSIController = $VirtualSCSIController.DeviceInfo.Label
$VirtualDisk.ControllerType = $VirtualSCSIController.GetType().Name
$VirtualDisk.DiskName = $VirtualDiskDevice.DeviceInfo.Label
$VirtualDisk.SCSI_ID = "$($VirtualSCSIController.BusNumber) : $($VirtualDiskDevice.UnitNumber)"
$VirtualDisk.DeviceName = $VirtualDiskDevice.Backing.DeviceName
$VirtualDisk.DiskFile = $VirtualDiskDevice.Backing.FileName
$VirtualDisk.DiskSize = $VirtualDiskDevice.CapacityInKB * 1KB / 1GB
$DiskInfo += $VirtualDisk
}}}
$DiskInfo | sort VMname, Diskname | Export-Csv -Path 'server_name.csv'
No comments:
Post a Comment