VMware Cloud Community
mk_ultra
Contributor
Contributor
Jump to solution

Set-Datastore -Name not working

What should be a simple one liner is driving me insane.

I am trying to rename a datastore on a new host via PowerCLI.

$IPAddress = [host IP address]
$HostName = [host name]
$ESXiHost = Get-VMHost $IPAddress
$DefaultDatastoreName = ($ESXiHost | Get-Datastore | where {$_.capacityGB -like "*95*"}).Name
$NewOSDatastoreName = $HostName+"_os"
$ESXIHost | Get-Datastore -Name $DefaultDatastoreName | Set-Datastore -Name $NewOSDatastoreName -Confirm:$False
 
I have confirmed each of these individual variables yields the correct object/string. I have tried eliminating variables by feeding in explicit strings.
No matter what I do, whenever I run the final line, it just returns the current datastore name:
 
Name FreeSpaceGB CapacityGB
---- ----------- ----------
temp_name 93.844 95.250
 
Please help!
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Are you connected to a vCenter or an ESXi node?
If that datastore is managed by a vCenter, you can't do the rename when connected to the ESXi node.
You have to be connected to the vCenter

I just tested that, and I see the same behavior you are seeing.
The Set-Datastore cmdlet might return some more info on the why.

From the ESXi Host Client you'll notice that the Rename Action is greyed out.


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Are you connected to a vCenter or an ESXi node?
If that datastore is managed by a vCenter, you can't do the rename when connected to the ESXi node.
You have to be connected to the vCenter

I just tested that, and I see the same behavior you are seeing.
The Set-Datastore cmdlet might return some more info on the why.

From the ESXi Host Client you'll notice that the Rename Action is greyed out.


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

mk_ultra
Contributor
Contributor
Jump to solution

Perfect! Thank you!

Tags (1)
Reply
0 Kudos