Hi All,
I'm trying to access the datastore browser function to list and delete the content of a VMFS datastore. I don't want to try and delete the datastore asnd re-create it as I have found that this fails as often as it works and I need something a bit more reliable.
Can anyone help please.
Best Regards,
Alasdair...............
Why don't you use the datastore provider (vmstore) ?
You can do something like this
del -Recurse vmstore:\<datacenter\<datastore>
Just make sure you have the correct path to the datastore. It will depend on the folders and the datacenter you have to specify to get to the datastore
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
I've done the following
Connect-VIServer -Server inf-vc.qavdc.com -user blah -password blah
$dStore = Get-Datastore -Name Local01
New-PSDrive -Location $dStore -Name Data1 -PSProvider VimDatastore -Root '\'
del -Recurse Data1:\
This deletes the content of the datastore, however I get the following error.
Remove-Item : This operation is supported only on datastore item objects. The pecified path '\sc-server01.qavdc.com@443\ha-datacenter\Local01\' is not a valid datastore item path.
At line:1 char:4
+ del <<<< -Recurse ds1:
+ CategoryInfo : InvalidArgument: ( , ViServerConn
ectionException
+ FullyQualifiedErrorId : Core_VmStoreProviderCache_TryValidatePathElement
s_NotDatastoreItem,Microsoft.PowerShell.Commands.RemoveItemCommand
Can you enlighten me as to what this means and how to fix it?
Best regards,
Alasdair
Hi,
You cannot delete the datastore itself - you need to call delete on its content:
$dStore = Get-Datastore -Name Local01 New-PSDrive -Location $dStore -Name Data1 -PSProvider VimDatastore -Root '\' del Data1:\* -Recurse
Regards,
Yasen Kalchev
PowerCLI Dev Team
Thanks for that. Much appreciated.
Hello
Thanks for information.
This method can also be used to browse the content of VMFS datastores and make stuff in it (usefull in my infrstructure)
$dStore = Get-Datastore -Name Local01
New-PSDrive -Location $dStore -Name Data1 -PSProvider VimDatastore -Root '\'
get-childitem Data1: