5 Replies Latest reply on Aug 11, 2017 9:44 AM by Zsoldier

    how to change "display name" via PowerCLI command?

    Ivy_Yang Lurker

      Hi, guys,

      I have a question:

      Vcenter----->home---->inventory--->host and Clusters, I select an ESX host and ------->configuration----->storage adapter, we can see many LUNs from storage.

      1.jpg

      We usually right click the "Name" to change the name to match with what we see in stroage side.

      file:///E:/1.jpg

       

      now we present 90 LUNs to this ESX cluster.

       

      I am wondering if there is any command we can change the device name?

       

      I tried get-ScsiLun.....and I can get the HLU, but there is no "Name" in the outpur.........

       

      would you help please point the right command?

       

      many thanks in advance!

        • 1. Re: how to change "display name" via PowerCLI command?
          Ivy_Yang Lurker

          actually I tried "UpdateScsiLunDisplayName" but does not work

           

           

           

          PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $esxName = “vh0034msg01.active.tan”

          PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $esx = Get-VMHost $esxName | Get-View

          PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $storSys = Get-View $esx.ConfigManager.StorageSystem

          PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-ScsiLun -VMHost $esxName -LUNType disk -CanonicalName "naa.6006016061902e0062f2319d68e5e111" |foreach {$_.RuntimeName,$_.Extensiondata.DisplayName}

          vmhba1:C0:T0:L10

          DGC Fibre Channel Disk (naa.6006016061902e0062f2319d68e5e111)

           

          PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-ScsiLun -VMHost $esxName -LUNType disk -CanonicalName "naa.6006016061902e0062f2319d68e5e111" | %{ $storSys.UpdateScsiLunDisplayName($_.DisplayName + " test") }

          Cannot find an overload for "UpdateScsiLunDisplayName" and the argument count:"1".

          At line:1 char:136

          + Get-ScsiLun -VMHost $esxName -LUNType disk -CanonicalName "naa.6006016061902e

          0062f2319d68e5e111" | %{ $storSys.UpdateScsiLunDisplayName <<<< ($_.DisplayName

          + " test") }

              + CategoryInfo          : NotSpecified: (:) [], MethodException

              + FullyQualifiedErrorId : MethodCountCouldNotFindBest

          • 2. Re: how to change "display name" via PowerCLI command?
            LucD Guru

            You're nearly there, but that method requires 2 parameters.

            Something like this

             

            $esxName = "vh0034msg01.active.tan" 
            $esx
            = Get-VMHost $esxName
            $storSys
            = Get-View $esx.ExtensionData.ConfigManager.StorageSystem Get-ScsiLun -VMHost $esxName -LUNType disk -CanonicalName "naa.6006016061902e0062f2319d68e5e111" | %{   $storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid, $_.DisplayName + " test") }
            • 3. Re: how to change "display name" via PowerCLI command?
              Ivy_Yang Lurker

              it works!!hiahai  thanks! 

              • 4. Re: how to change "display name" via PowerCLI command?
                KFM Enthusiast

                Sorry to revive an old thread but I don't know if I'm going crazy or something has changed in 2017....but it looks like $_.DisplayName is no longer a property of a ScsiLun object?

                 

                Having said that I'm trying to achieve something similar to this (and a lot of other posts on this forum) but can't seem to work it out. Basically I want to rename the SCSI LUN Display Name property to match that of the datastore name. I can't seem to find a common property that links the two together.

                 

                I can't find a reference to the datastore name in the ScsiLun object to use as a argument to UpdateScsiLunDisplayName. Conversely there is no canonical name in a datastore object returned from Get-Datastore.

                • 5. Re: how to change "display name" via PowerCLI command?
                  Zsoldier Expert

                  It's part of $_.Extensiondata.DisplayName

                  • 6. Re: how to change "display name" via PowerCLI command?
                    KFM Enthusiast

                    Ok cool - I got that, thanks!

                     

                    Any ideas on how to solve my original problem?

                    • 7. Re: how to change "display name" via PowerCLI command?
                      LucD Guru

                      The example script becomes

                       

                      $esxName = "vh0034msg01.active.tan"

                      $esx = Get-VMHost $esxName

                      $storSys = Get-View $esx.ExtensionData.ConfigManager.StorageSystem

                      Get-ScsiLun -VMHost $esxName -LUNType disk -CanonicalName "naa.6006016061902e0062f2319d68e5e111" | %{

                        $storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid, $_.ExtensionData.DisplayName + " test")

                      }

                      • 8. Re: how to change "display name" via PowerCLI command?
                        KFM Enthusiast

                        Hi Luc,

                         

                        Thanks for that but that doesn't really meet what I was hoping to solve. Essentially what I'm trying to do is outlined in this blog post Renaming vSphere Datastore device display names – Cloud/Virtualisation/Automation

                         

                        Any hints/tips you can pass along?

                         

                         

                        Thanks,
                        Kam

                        • 9. Re: how to change "display name" via PowerCLI command?
                          LucD Guru

                          You will have to change the 2nd parameter on the UpdateScsiLunDisplayName method.

                          In that post the author changes the name to the name of the datastore that is allocated on the LUN.

                           

                          The updated script would look something like this

                          It will change the devicename for each LUN, that is used for the datastores starting with 'MyDS' on ESXi node 'MyEsx', to the datastorename.

                          As the post you refer to is doing manually.

                          I just tested this again on vSphere 6.5, and it works.

                           

                          $esxName = 'MyEsx'

                          $dsName = 'MyDS*'

                           

                          $dsTab = @{}

                          Get-Datastore -Name $dsName | %{

                            $dsTab.Add($_.ExtensionData.Info.Vmfs.Extent[0].DiskName,$_.Name)

                          }

                           

                          $esx = Get-VMHost $esxName

                          $storSys = Get-View $esx.ExtensionData.ConfigManager.StorageSystem

                           

                          Get-ScsiLun -VMHost $esxName -LUNType disk | where{$dsTab.Keys -contains $_.CanonicalName} | %{

                            $storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid, "$($dsTab[$_.CanonicalName])")

                          1 person found this helpful
                          • 10. Re: how to change "display name" via PowerCLI command?
                            KFM Enthusiast

                            Hi Luc,

                             

                            Again you come through the with the goods. I knew there should be some correlation between a datastore and scsilun object but just couldn't find it. Thanks for pointing it out

                             

                            Thanks so much!

                             

                             

                            Cheers,
                            Kam