Automation

 View Only
  • 1.  RDMs naa ID and SCSI controller type through Get-View

    Posted Jan 23, 2018 06:31 PM

    Hello, I have the script below which works fine but I would like to read the naa ID of the RDM rather than the vml ID. Also I'm trying to get the scsi adapter type for the RDMs (VMware PVSCSI, LSI Logic SAS...). This script uses Get-View and that is how I would like to keep it as we have quite an amount of VMs to scan through. I know I can achieve that through get-scsicontroller but again, I am trying without success to see how to get those properties through Get-View.

    $report = @()

    #$vCluster = Read-Host 'enter the vCluster name'

    $vms = Get-Datacenter myDC | Get-VM | Get-View

    foreach($vm in $vms)

        {

        foreach($dev in $vm.Config.Hardware.Device)

           {

           if(($dev.gettype()).Name -eq "VirtualDisk")

             {

             if($vm.config.Hardware.Device.sharedbus -eq "physicalSharing")

                {

                $row = "" | select VMName, HWLevel, ESXiHost, HDDeviceName, HDFileName

                $row.VMName = $VM.Name

                $row.HWLevel = $VM.config.Version

                $row.ESXiHost = (get-vm $vm.Name).VMHost

                $row.HDDeviceName = $dev.Backing.DeviceName

                $row.HDFileName = $dev.Backing.FileName

                $report += $row

                }

             }

           }

        }



  • 2.  RE: RDMs naa ID and SCSI controller type through Get-View
    Best Answer

    Posted Jan 23, 2018 07:14 PM

    Try like this.
    There was a small error in your logic to detect the shared bus, that needs to be done on the controller, not the disk

    #$vCluster = Read-Host 'enter the vCluster name' 

    $vms = Get-Datacenter myDC | Get-VM | Get-View 

     

     

    $report = foreach($vm in $vms){ 

        foreach($dev in $vm.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualSCSIController]}){

            if($dev.SharedBus -eq 'physicalSharing'){

                $vm.Config.Hardware.Device | where{$dev.Device -contains $_.Key} |

                Select @{N='VM';E={$vm.Name}},

                    @{N='HWLevel';E={$vm.config.Version}},

                    @{N='ESXiHost';E={(Get-VM $vm.Name).VMHost.Name}},

                    @{N='Controller';E={$dev.GetType().Name}},

                    @{N='HDDeviceName';E={$_.Backing.DeviceName}},

                    @{N='HDFileName';E={$_.Backing.FileName}}

            } 

        }

    }



  • 3.  RE: RDMs naa ID and SCSI controller type through Get-View

    Posted Jan 23, 2018 07:33 PM

    many thanks indeed Luc, that worked great! I'll do some text manipulation to carve out the naa ID out of the vml ID,

    cheers!