Highlighted
Contributor
Contributor

How can I rename a device object within esxcli.storage.core.device object...

Jump to solution

Hi all,

I have accidentally renamed one of my ESXCLI device objects by using .setconfig.invoke($array)

The $array accidentally contained two values which contained the reference device name along with its IsSharedClusterwide value

I have since corrected this, however unfortunately one of my disk objects now has the following value:

Device : @{Device=<naa.ref>; IsSharedClusterWide=true}

How can I select this one disk object within the esxcli array and correct the device name?

Many thanks

0 Kudos
1 Solution

Accepted Solutions
Highlighted
User Moderator
User Moderator

Strange, are you sure that is actually representing an actual LUN and not some pseudo device?

Did you check in the Web Client under Devices if the original LUN is present or not?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
11 Replies
Highlighted
User Moderator
User Moderator

Does that device show up when you do?

$esxcli.storage.core.device.list.Invoke() | where{$_.DisplayName -match '@{'}


If you have the canonicalname of the LUN, you could try something like this

$canonicalname = 'naa.60003ff44dc75adc9e0192ec73661234'

$esxcli.storage.core.device.set.Invoke(@{device=$canonicalname;name='<newname>'})


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Contributor
Contributor

Hi LucD,

Many thanks for your reply

Unfortunately it is the canonicalname of the LUN that has been changed, not the displayname

the device value now contains the cononicalname along with the issharedclusterwide value as I did not specify the singular value from the array object

so now I have for this particular disk:

Device          :  @{Device=eui.123456789; IsSharedClusterWide=true}

I have created two new array objects called $Wrong = '@{Device=eui.123456789; IsSharedClusterWide=true' and $Right = 'Device=eui.123456789'

But I cannot see how I reference this object in the esxcli output to then change it immediately after if that makes sense?

0 Kudos
Highlighted
User Moderator
User Moderator

Can you share the output of device.list for that specific LUN?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Contributor
Contributor

Hi LucD,

Below is a snapshot of the affected LUN,

err.jpg

As you can see, Device is unfortunately now incorrect, containing the two object array entry

Thanks

0 Kudos
Highlighted
User Moderator
User Moderator

Strange, are you sure that is actually representing an actual LUN and not some pseudo device?

Did you check in the Web Client under Devices if the original LUN is present or not?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
Highlighted
Contributor
Contributor

No, it does not show up in vcenter and indeed it does seem to be some kind of pseudo device as the disk device type = 'No device type' and it has no associated LUN value

0 Kudos
Highlighted
User Moderator
User Moderator

Does it disappear when you do

$esxcli.storage.core.device.purge.Invoke()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Contributor
Contributor

Hi,

I ran the command which ended with true but unfortunately the disk device is still there

0 Kudos
Highlighted
User Moderator
User Moderator

Strange.
I have no clue how you were able to create that entry.
I can't seem to reproduce it.

Since that entry is not visible in the Web Client, I wonder if it is something in the $esxcli object itself.
Have you tried stopping/starting your PowerShell session?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Contributor
Contributor

Hi LucD,

Yes I have started a new PS console a few times now and run the script where it stops after changing the first device and it is working as expected

Indeed very strange how these odd occurrences happened when I accidentally applied an array object with two values although like you say, the affected storage LUNS are not actual disk devices so I will investigate with our storage guys to try to establish what these actually are

Do you know of any articles which fully cover powercli/esxcli and configuring storage devices as most of what I have found is relatively sparse?

Thank you again so much for your invaluable assistance!

0 Kudos
Highlighted
User Moderator
User Moderator

The commands you run via Get-EsxCli are exactly the same as the esxcli commands you would run on an ESXi console.

Consult the documentation for the esxcli command, see ESXi 7.0 ESXCLI Command Reference


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos