VMware Cloud Community
lorried82
Enthusiast
Enthusiast

error thrown when using remove-datastore cmdlet

I am running the command below

Remove-Datastore -Datastore datastore -VMHost host -Confirm:$False

the error gets thrown

Remove-Datastore A specified parameter was not correct - full error output attached (hostname has been blacked out)

am I missing something obvious?

Any help appreciated.

0 Kudos
10 Replies
LucD
Leadership
Leadership

Did you check that

Get-VMHost -Name host

and

Get-Datastore -Name datastore

both return objects?


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

0 Kudos
lorried82
Enthusiast
Enthusiast

yes - I was able to add it just fine but when I try and remove I get that error.

0 Kudos
lorried82
Enthusiast
Enthusiast

I should note when I do get-datastore -name datastore it does return it 7 times - is that odd?

0 Kudos
lorried82
Enthusiast
Enthusiast

ok so I just ran the command again and let it run through and it did complete successfully one time out of 7 tires. so the issue must be the weirdness on why it returns 7 results - any thoughts on that?

0 Kudos
LucD
Leadership
Leadership

Do you have multiple connections open?

Check what is in $global:defaultviservers


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

0 Kudos
lorried82
Enthusiast
Enthusiast

when I run that command I am just seeing the one server connection.

0 Kudos
LucD
Leadership
Leadership

Ok, one connection is ok.

Is that to a vCenter?

Are there perhaps 7 ESXi nodes connected to that vCenter?
Or are there datastores with names that closely resemble each other?
Can you show the output with the 7 datastores that are returned?


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

0 Kudos
lorried82
Enthusiast
Enthusiast

Yes to a vCenter.

There are 30+ ESXi servers that are connected to the vCenter but now that you say that I think the issue is that the datastore is in 7 different dataCenters so maybe that is my issue? I need to add the -Location attribute

would that make sense?

0 Kudos
LucD
Leadership
Leadership

Yes, but is it the datastorename that was reused, or are all these datastores using the same LUN?

And you would need to do

$dc = Get-Datacenter -Name datacenter

Get-Datastore -Name datastore -VMHost host -Location $dc |

Remove-Datastore -Confirm:$false


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

0 Kudos
lorried82
Enthusiast
Enthusiast

yes the datastore name is reused since it is an NFS mount

ok that makes sense thank you!

0 Kudos