10 Replies Latest reply on Jan 9, 2019 10:10 PM by LucD

    Get Virtual Disk SCSI-IDs

    DaHess_DNVGL Novice

      Hi,

       

      Is there an easy way to get the SCSI-ID of a VMs Virtual Disks displayed in a Get-VM | Get-Harddisk output?

      So far I could not find a way to retrieve the SCSI-IDs for the Virtual Disks in the same output as "Get-HardDisk".

      It is simply not available, but it my opinion it should be there out of the box.

       

      I managed to get the SCSI-IDs of the Virtual Disks by importing this function and then run the command Get-VM <MyVM>  | Get-VMDisk,

      but I don't like the output really and I would rather like to have an Object "SCSI-ID" in the "Get-Harddisk" cmdlet output.

        • 1. Re: Get Virtual Disk SCSI-IDs
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          One easy way is with a calculated property.

           

          Get-VM | Get-HardDisk |

          Select @{N='VM';E={$_.Parent.Name}},Name,@{N='SCSIid';E={$_.ExtensionData.UnitNumber}}

          • 2. Re: Get Virtual Disk SCSI-IDs
            DaHess_DNVGL Novice

            Hi Luke,

            thanks for your quick reply.

            That  comes close to what I was looking for, but it is still missing the Controller-ID.

             

            As an example, here the output for one of our Oracle RAC-Node VMs:

             

            PS P:\> Get-VM OSL2420 | Get-HardDisk | Select @{N='VM';E={$_.Parent.Name}},Name,@{N='SCSIid';E={$_.ExtensionData.UnitNumber}}

             

            VM      Name         SCSIid

            --      ----         ------

            OSL2420 Hard disk 1       0

            OSL2420 Hard disk 2       1

            OSL2420 Hard disk 14      2

            OSL2420 Hard disk 18      3

            OSL2420 Hard disk 19      4

            OSL2420 Hard disk 20      5

            OSL2420 Hard disk 21      6

            OSL2420 Hard disk 15      0

            OSL2420 Hard disk 16      1

            OSL2420 Hard disk 17      2

            OSL2420 Hard disk 3       3

            OSL2420 Hard disk 4       4

            OSL2420 Hard disk 5       5

            OSL2420 Hard disk 22      6

            OSL2420 Hard disk 23      8

            OSL2420 Hard disk 24      9

            OSL2420 Hard disk 25     10

            OSL2420 Hard disk 6       0

            OSL2420 Hard disk 7       1

            OSL2420 Hard disk 8       2

            OSL2420 Hard disk 9       3

            OSL2420 Hard disk 10      4

            OSL2420 Hard disk 11      5

            OSL2420 Hard disk 12      0

            OSL2420 Hard disk 13      1

             

             

            The vital piece of information I am missing in the output is the complete SCSI-ID that shows the controller ID followed by the Disk-ID in the same form as it is shown in the VM-Settings Dialog in the vSphere-Client.

            The Disk-ID on its own is useless if you use more than one SCSI-Controller.

             

            Is there any chance to get that full SCSI-ID displayed?

            • 3. Re: Get Virtual Disk SCSI-IDs
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Ok, try like this

               

              Get-VM | Get-HardDisk -PipelineVariable hd |

              Select @{N='VM';E={$_.Parent.Name}},Name,@{N='SCSIid';E={

                  $ctrl = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.ControllerKey}

                  "$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"}}

              • 4. Re: Get Virtual Disk SCSI-IDs
                DaHess_DNVGL Novice

                that didnt help either.

                The output leaves the SCSI-ID Column empty.:

                 

                VM      Name         SCSIid
                --      ----         ------
                OSL2420 Hard disk 1
                OSL2420 Hard disk 2
                OSL2420 Hard disk 14
                OSL2420 Hard disk 18
                OSL2420 Hard disk 19
                OSL2420 Hard disk 20
                OSL2420 Hard disk 21
                OSL2420 Hard disk 15
                OSL2420 Hard disk 16
                OSL2420 Hard disk 17
                OSL2420 Hard disk 3
                OSL2420 Hard disk 4
                OSL2420 Hard disk 5
                OSL2420 Hard disk 22
                OSL2420 Hard disk 23
                OSL2420 Hard disk 24
                OSL2420 Hard disk 25
                OSL2420 Hard disk 6
                OSL2420 Hard disk 7
                OSL2420 Hard disk 8
                OSL2420 Hard disk 9
                OSL2420 Hard disk 10
                OSL2420 Hard disk 11
                OSL2420 Hard disk 12
                OSL2420 Hard disk 13

                • 5. Re: Get Virtual Disk SCSI-IDs
                  LucD Guru
                  vExpertCommunity WarriorsUser Moderators

                  Which PowerShell version are you using?

                  Do a $PSVersionTable.

                  The Pipeline variable I used was introduced in PS v4

                  • 6. Re: Get Virtual Disk SCSI-IDs
                    DaHess_DNVGL Novice

                    Hi Luke,

                     

                    PS P:\> $PSVersionTable.PSVersion

                     

                    Major  Minor  Build  Revision

                    -----  -----  -----  --------

                    5      1      15063  726

                     

                     

                    PowerCLI Version

                    ----------------

                       VMware PowerCLI 6.5.1 build 5377412

                    ---------------

                    Component Versions

                    ---------------

                       VMware Cis Core PowerCLI Component 6.5 build 6983166

                       VMware VimAutomation Core PowerCLI Component 6.5 build 6234650

                    • 7. Re: Get Virtual Disk SCSI-IDs
                      LucD Guru
                      Community WarriorsUser ModeratorsvExpert

                      Strange, that is exactly the same as I have.

                       

                      And what happens when we leave out the pipelinevariable?

                       

                      Get-VM | Get-HardDisk |

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

                          Name,

                          @{N='SCSIid';E={

                              $hd = $_

                              $ctrl = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.ControllerKey}

                              "$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"

                           }}

                      1 person found this helpful
                      • 8. Re: Get Virtual Disk SCSI-IDs
                        DaHess_DNVGL Novice

                        Hey Luke,

                         

                        this time the output looks much better. Thank you very much.

                         

                        VM      Name         SCSIid

                        --      ----         ------

                        OSL2420 Hard disk 1  0:0

                        OSL2420 Hard disk 2  0:1

                        OSL2420 Hard disk 14 0:2

                        OSL2420 Hard disk 18 0:3

                        OSL2420 Hard disk 19 0:4

                        OSL2420 Hard disk 20 0:5

                        OSL2420 Hard disk 21 0:6

                        OSL2420 Hard disk 15 1:0

                        OSL2420 Hard disk 16 1:1

                        OSL2420 Hard disk 17 1:2

                        OSL2420 Hard disk 3  1:3

                        OSL2420 Hard disk 4  1:4

                        OSL2420 Hard disk 5  1:5

                        OSL2420 Hard disk 22 1:6

                        OSL2420 Hard disk 23 1:8

                        OSL2420 Hard disk 24 1:9

                        OSL2420 Hard disk 25 1:10

                        OSL2420 Hard disk 6  2:0

                        OSL2420 Hard disk 7  2:1

                        OSL2420 Hard disk 8  2:2

                        OSL2420 Hard disk 9  2:3

                        OSL2420 Hard disk 10 2:4

                        OSL2420 Hard disk 11 2:5

                        OSL2420 Hard disk 12 3:0

                        OSL2420 Hard disk 13 3:1

                        • 9. Re: Get Virtual Disk SCSI-IDs
                          bernz Novice
                          Hi LucD, this helps pretty much... how can you add another field like each VMDK path/location?
                          • 10. Re: Get Virtual Disk SCSI-IDs
                            LucD Guru
                            User ModeratorsvExpertCommunity Warriors

                            Try like this

                             

                            Get-VM | Get-HardDisk |

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

                              Name, Filename,

                               @{N='SCSIid';E={

                               $hd = $_

                               $ctrl = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.ControllerKey}

                               "$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"

                               }}