Hi,
We have list of Orphaned VMDK's in datastores and I am looking for PowerCLI script to delete those VMDK's directly from datastore.
The list is in excel format which contains vCenters name, Datastore Name and Disk(VMDK) path and last modification date/time.
Looking for script with check condition whether VMDK is connected to any VM or not, if not connected then proceed with deletion.
NOTE: Datastores are VVOLS
Thanks.
I don't have any VVOLs to test, but with the following you should be able to map datastore names to part of those paths you have.
Get-Datastore -PipelineVariable ds | where{$_.Type -eq 'VVOL'} |
ForEach-Object -Process {
$_.ExtensionData.Info |
Select @{N='DS';E={$ds.Name}},*
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you try the script in Orphaned Files Revisited?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your reply.
Can you help me with script to delete orphaned vmdk from the given datastore path. Before it delete, need to include a check whether VMDK is connected to any VM or not.
Thanks.
That is exactly what that blog post is showing.
Did you read the post and try the script?
If you want a Delete switch, that is what my other post Orphaned files and folders – Spring cleaning is providing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi
I have path like below, can you tell me how to get this into script to identify the datastore.
ds:///vmfs/vvol/d48954a25695-8hfyrd475jfurjfv/fcr4111.ca4564c7-7c70-470e-aeec/vmname.vmdk
Thanks.
How did you obtain this path?
And how is this related to your original question about orphaned VMDKs?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Actually datastores are vvols and all orphaned VMDK's are residing on these paths. I understand this is kind of root path, but these data pulled out by using a tool and it gives data in this way, Can we have any way to include in script to identify the datastore by using this root path?
Thanks
I don't have any VVOLs to test, but with the following you should be able to map datastore names to part of those paths you have.
Get-Datastore -PipelineVariable ds | where{$_.Type -eq 'VVOL'} |
ForEach-Object -Process {
$_.ExtensionData.Info |
Select @{N='DS';E={$ds.Name}},*
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Tried a lot but I couldn't make this, Can you please help me with the script. My requirement is just want to delete the VMDK from below datastore path provided through .CSV file. Before it deletes need to check whether its connected to any VM or not.
ds:///vmfs/vvol/d48954a25695-8hfyrd475jfurjfv/fcr4111.ca4564c7-7c70-470e-aeec/vmname.vmdk
Thanks.
Since I don't use/have VVOLs I can't test, so I rely on what you see, but "... but I couldn't make this" doesn't really help I'm afraid.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
It helps, I can get the root path datastore but, I don't know how to browse the VMDK exactly to path in powercli script. It would be very much helpful if you help me with the script. Apart from vvols, I have other VMFS datastores as well.
Thanks.
Hi there,
I have exactly the same situation . were you able find a PowerCLI cmd (or script) to delete orphaned VMDK with the path like ds:///vmfs/vvol/d48954a25695-8hfyrd475jfurjfv/fcr4111.ca4564c7-7c70-470e-aeec/vmname.vmd ?
Thanks,