VMware Cloud Community
ibuamod
Contributor
Contributor

Clean datastore ( remove all unregistered VMs and keep only register vms ) using powercli

I have a Datastore which is really full, and I need to clean it, I am looking for a powercli script that will clean the datastore and only keep the

VMs that are registered

Reply
0 Kudos
12 Replies
luwenwei
Contributor
Contributor

哪问题?

Reply
0 Kudos
luwenwei
Contributor
Contributor

What's the problem?

Reply
0 Kudos
ibuamod
Contributor
Contributor

I need to delete the unregistered Vms from the datastore ? I don't know how to do it in powercli ? How to list all the vms that are not registered

Reply
0 Kudos
luwenwei
Contributor
Contributor

Sorry, you have a search engine search.

Reply
0 Kudos
ibuamod
Contributor
Contributor

it looks like you are new to the fourms

Reply
0 Kudos
luwenwei
Contributor
Contributor

Yes, novice

Reply
0 Kudos
LucD
Leadership
Leadership

Have a look at my Orphaned Files Revisited post


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

Reply
0 Kudos
ibuamod
Contributor
Contributor

Great link but these I need to delete other VMs not only Orphaned Vms

Reply
0 Kudos
ibuamod
Contributor
Contributor

I only want to keep the registered VMs

Reply
0 Kudos
LucD
Leadership
Leadership

What other VMs, besides registered and unregistered (orphaned), do you have then?


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

Reply
0 Kudos
ibuamod
Contributor
Contributor

what understand from VMware states that there is a registered VM and there is an Orphaned VM but if you remove a VM from the inventory it will not be Orphaned

Reply
0 Kudos
LucD
Leadership
Leadership

That is correct if you use for example the Remove-VM cmdlet with the DeletePermanently switch.

If you don't use that switch, the VM will be unregistered and the files on the datastore for that VM, which will not be removed, will represent an orphaned VM.

The script I pointed to earlier finds such orphaned VMs, in other words it finds VMs sitting on the datastore, but not in the inventory.


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

Reply
0 Kudos