Hi Friends
Looking for a script to delete folders with its contents from a Datastore , I tried to do it with below Managed object , but not able to find a method that can be used for deleting a folder
Appreciate if anyone can help with it
SearchDatastoreSubFolders_Task(searchSubFolders)
Thanks
Jooshil
You need the FileManager for that.
Try like this, it will delete the folder and all its content.
$dcName = 'MyDC'
$dc = Get-Datacenter -Name $dcName
$si = Get-View ServiceInstance
$fileMgr = Get-View -Id $si.Content.FileManager
$fileMgr.DeleteDatastoreFile($file, $dc.ExtensionData.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You need the FileManager for that.
Try like this, it will delete the folder and all its content.
$dcName = 'MyDC'
$dc = Get-Datacenter -Name $dcName
$si = Get-View ServiceInstance
$fileMgr = Get-View -Id $si.Content.FileManager
$fileMgr.DeleteDatastoreFile($file, $dc.ExtensionData.MoRef)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc
That works
HI LUC,
is there any script to Delete the Empty folders in Data stores.
This will also delete an empty folder.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great, please need a script to delete the ONLY empty folders in Datastore. we don't want touch any other folders.