uuid,DisplayName
naa.60000970000120001295533030303031,PowerMax_odd_system_device
naa.60000970000120001297533030303031,PowerMax_even_system_device
$csv = import-csv "$env:USERPROFILE\Input\testrename.csv"
$esx = "mytest.com"
$storSys = Get-View $esx.ConfigManager.StorageSystem
Foreach ($item in $csv){
$uuid = $item.uuid
$newname = $item.DisplayName
Get-ScsiLun -VMHost $esx -LUNType disk -CanonicalName $uuid | %{
$storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid,$newname)
}
}
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:4 char:21
+ $storSys = Get-View $esx.ConfigManager.StorageSystem
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Perhaps try like this
#****************************************************************
$csv = import-csv "$env:USERPROFILE\Input\testrename.csv"
$esx = Get-VMHost -Name "mytest.com"
$storSys = Get-View $esx.ExtensionData.ConfigManager.StorageSystem
Foreach ($item in $csv){
$uuid = $item.uuid
$newname = $item.DisplayName
Get-ScsiLun -VMHost $esx -LUNType disk -CanonicalName $uuid | %{
$storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid,$newname)
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Before I open this new one, I have referenced the following posts in the past
https://www.eehelp.com/question/powercli-script-to-update-scsi-lun-displayname/
Perhaps try like this
#****************************************************************
$csv = import-csv "$env:USERPROFILE\Input\testrename.csv"
$esx = Get-VMHost -Name "mytest.com"
$storSys = Get-View $esx.ExtensionData.ConfigManager.StorageSystem
Foreach ($item in $csv){
$uuid = $item.uuid
$newname = $item.DisplayName
Get-ScsiLun -VMHost $esx -LUNType disk -CanonicalName $uuid | %{
$storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid,$newname)
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Can you please remove the real ESXi host name in you reply, I noticed that and changed it already to $esx = "mytest.com"
Thanks
Hi Luc,
The script worked, but get some error, it rename two of the LUNs in my csv successfully to $newname
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:4 char:21
+ $storSys = Get-View $esx.ConfigManager.StorageSystem
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
You missed the ExtensionData part in my code
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot for your quick response and helps, tested working without errors now!
