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.
We usually right click the "Name" to change the name to match with what we see in stroage side.
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!
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") }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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") }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
:smileysilly:it works!!hiahai thanks!
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.
It's part of $_.Extensiondata.DisplayName
Ok cool - I got that, thanks!
Any ideas on how to solve my original problem?
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")
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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])")
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
This is a faster way to rename the "Display Name". In a CSV have a column for Name and Identifier. The Name will be the "Display Name" and the Identifier will be the naa. name. The biggest pain is matching up the naa. names to the LUNs on your storage.
Connect-VIServer -Server @("vCenter")
$myesxcli= get-VMHost vSphere_Host
$NAA = Import-csv .\VMWare_Luns.csv
$storSys = Get-View $myesxcli.ExtensionData.ConfigManager.StorageSystem
$GSL = Get-ScsiLun -VMHost $myesxcli.name -LUNType disk -CanonicalName *
Foreach ($LUN in $NAA ) {
$UUID = $null
$UUID = ($GSL |Where-Object {$_.CanonicalName -eq $LUN.Identifier}).ExtensionData.Uuid
If ($UUID) {
write-host ("Updating " + $LUN.Identifier + " with UUID of " + $UUID + " to Display name: " + $LUN.Name)
$storSys.UpdateScsiLunDisplayName($UUID, $LUN.Name)
}
}