VMware Cloud Community
routing7
Contributor
Contributor

I want to add disk format info to the existing script

Hello,

I've a PowerCLI script available and I would to like add a step to show the disk format information (Thick - lazy or eager, Thin etc). And also the current script output is not sorting out the "disk name column" with hard disk number.

can some one help...

 

$report = @()

$VMs = Get-content .\servers.txt

 

Foreach ($VM in $VMs){

    #$LUN = ""

    $VmView = Get-View -ViewType VirtualMachine -Filter @{"Name" = $VM}

        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})) {

                    $VMinfo               = Get-VM $VM

                    $line                 = "" | Select 'Name', 'ClusterName', 'DiskName', 'SCSI_ID', 'DiskFile', 'DiskSize(GB)'

                    $line.'Name'          = $VMinfo.name

                    $line.'ClusterName'   = $VMInfo.VMhost.Parent

                    $line.'DiskName'      = $VirtualDiskDevice.DeviceInfo.Label

                    $line.'SCSI_ID'       = "$($VirtualSCSIController.BusNumber) : $($VirtualDiskDevice.UnitNumber)"

                    $line.'DiskFile'      = $VirtualDiskDevice.Backing.FileName

                    $line.'DiskSize(GB)'  = ($VirtualDiskDevice.CapacityInKB * 1KB / 1GB)

                    $Report              += $line

                }

        }

}

$report | Export-csv .\report1.csv -NoTypeInformation -UseCulture

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

I think I already answered that in Solved: SCSIcanonicalname? - VMware Technology Network VMTN


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
routing7
Contributor
Contributor

I've added first two steps from my old script to get the VM details from the input file. However, it is not working as expected

Reply
0 Kudos
LucD
Leadership
Leadership

What is not working?
You have to provide a bit more information


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos