1 2 3 4 Previous Next 50 Replies Latest reply on Jul 18, 2017 6:39 AM by LucD Go to original post
      • 30. Re: list disks rdm with powershell
        LucD Guru
        vExpertUser ModeratorsCommunity Warriors

        Try the attached version

        1 person found this helpful
        • 31. Re: list disks rdm with powershell
          mburutzis Enthusiast

          Awesome! You are the best!

           

          Thank you very much!

          • 32. Re: list disks rdm with powershell
            chaderic20 Lurker

            LucD, thanks for posting that script!  It's gotten me halfway to the report I'm trying to build.  I'm wondering if someone here can help me get the rest of the info I want.

            I'm trying to build a report that has the following columns:  Host, VM, Disk Number, LUN ID, Runtime Name, Target, Status.  Using LucD's script as a starting point I've got a script that will give me the first 4 columns, but can't figure out where to get the Runtime Name, Target or Status.  Another problem is that this appears to only show each disk once, and I'm going to want each disk 4 times (once for each path - two HBA's, each dual pathed - because the runtime name will be different for each path).  My script is attached, any help you all can give me would be appreciated!  Thanks!

            • 33. Re: list disks rdm with powershell
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

              To get the terminology clear, you mean RuntimeName, Target and Status as it appears on the View Paths panel in the vSphere Client ?

              • 34. Re: list disks rdm with powershell
                chaderic20 Lurker

                Yes, that is correct.  Thanks!

                • 35. Re: list disks rdm with powershell
                  chaderic20 Lurker

                  Here is my latest script for anyone who may find it useful.  I've added a couple more fields other than what my previous post said I was looking for.  And I never could find where to get the Target or Status fields, but my customer said that wasn't important, so I'm not too worried about getting it.  If anyone knows how/where to get those though, I'd still be interested in learning.

                  • 36. Re: list disks rdm with powershell
                    Priergaard Novice

                    Hi
                    I have tried to run your script, but report.csv is empty, what do I do wrong?

                    Best regards

                    Henrik Priergaard 

                    • 37. Re: list disks rdm with powershell
                      chaderic20 Lurker

                      Henrik,

                       

                      Here is the most recent version of the script that I'm using.  There are a couple of lines you will need to change where I've removed my company's information and you'll have to put your company's information in.

                       

                      In the line:

                           Connect-VIServer -Server servername -WarningAction:SilentlyContinue

                      You will need to replace "servername" with the name of the vCenter server you want to connect to.  You will also need to run the script under a user account that has access to that vCenter server, or you will need to specifiy other credentials in the script.

                       

                      In the line:

                           foreach ($folder in (Get-View -ViewType "Folder" -Filter @{"Name" = "Folder name"}))

                      You will need to replace "Folder name" with the actual name of the folder you want to gather info from.  I only care about certain folders, so that is why I filter it down like that.  If you want to run the script against everything and not filter down to certain folders you can replace that entire for-loop with the lines:

                           $Hosts += Get-View -ViewType "HostSystem"

                           $VMs += Get-View -ViewType "VirtualMachine"

                       

                       

                      I think that should get you a report if you do that.  Let me know if you still have problems.

                       

                       

                      Chad

                      • 38. Re: list disks rdm with powershell
                        AmolPatil Novice

                        Hello Chad,

                        Its good script. But I am looking a script to get the selected VM or all the VMs who has DiskType -eq “RawPhysical”, details with Properties (Host, VM, DiskNumber, Identifier, Policy, VirtualDeviceNode, Capacity )

                        Can you assist ?

                        I tried this as below --

                         

                        Function Get-RAWDiskInfo {

                        $RDisks = Get-VM $VM | Get-HardDisk | Where {$_.DiskType -eq “RawPhysical”}

                        Foreach ($RDisk in $RDisks) {

                        $Lun = Get-VMHost -name (Get-VM $VM).VMHost | Get-SCSILun $RDisk.SCSICanonicalName

                         

                        $Props = @{ 'VM Name' = $RDisk.Parent;

                                    'DiskType' = $RDisk.DiskType;

                                    'Name' = $RDisk.Name;

                                    'Filename' = $RDisk.Filename;

                                    'Scsi Name' = $RDisk.ScsiCanonicalName;

                                    'LUN ID' = $Lun.RuntimeName.Substring($Lun.RuntimeName.LastIndexof(“L”)+1)

                                 

                                    }

                        New-Object -TypeName PSObject -Property $props

                        }

                        }

                        • 39. Re: list disks rdm with powershell
                          dskwared Novice
                          vExpert

                          LucD, thanks for this script with the DisplayName added! It really helped me find the information I was looking for! Thank you!

                          • 40. Re: list disks rdm with powershell
                            kumarsenthild Hot Shot

                            Big thanks to you. I am following you past 4 years.. When ever i am searching any script for PowerCli, at least google will provide your two scripts.

                             

                            Now my requirement is need VM information with RDM status only ( RDM presented or not). Not required for RDM details. I have modified your script.

                            Request to review the script. i will believe i done some mistake.

                            @LucD

                            • 41. Re: list disks rdm with powershell
                              LucD Guru
                              User ModeratorsCommunity WarriorsvExpert

                              Try like this

                               

                              $report = @()

                              $vmList = Get-Content C:\temp\VM.txt

                              $vms = Get-VM $vmList

                              foreach($vm in $vms){

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

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

                                     if($dev.Backing.CompatibilityMode -eq "physicalMode")

                                   {

                              $rdm = "yes"

                                      }

                                  else {

                                  $rdm = "no"

                                  }

                              $row = "" | select VMName, Cluster, ESXHost, Datastore, NetworkName, RDM

                                       $row.VMName = $vm.Name

                              $row.Cluster = get-cluster -VM $vm

                                       $row.ESXHost = Get-VMHost -VM $vm

                              $row.Datastore = Get-Datastore -VM $vm

                                       $row.NetworkName = (get-vm $vm | Get-NetworkAdapter).NetworkName

                              $row.RDM = $rdm

                                       $report += $row

                                   }

                                }

                              }

                              $report

                              1 person found this helpful
                              • 42. Re: list disks rdm with powershell
                                kumarsenthild Hot Shot

                                As Usually you are awesome

                                 

                                Working like a charm.

                                 

                                Really appreciate your help.

                                • 43. Re: list disks rdm with powershell
                                  kumarsenthild Hot Shot

                                  Hi LuCD,

                                   

                                  One more help, after running this script i am getting multiple lines of same VM( Based on number of disk). Is it possible to display only one line for VM and need to add vCenter name in additional column. .