Automation

 View Only
Expand all | Collapse all

List VMs in datastore that is not in inventory

klee222

klee222Feb 12, 2018 07:28 AM

klee222

klee222Feb 12, 2018 09:55 AM

  • 1.  List VMs in datastore that is not in inventory

    Posted Oct 26, 2015 02:33 PM

    Hi Guys

    PowerCLI rookie here, so sorry for stupid questions.

    I’m trying to clean up a bunch of singehost with local datastores. So I need a script that can output a list of virtual machine files on a datastore that is not being used by VMs in the inventory. One of the problem is that the files on the datastore, is not all ways named exactly the same as the VM’s in the inventory.

    Been looking at this, but I think the term “orphaned” is ‘sent what I think it is:

    https://communities.vmware.com/thread/266913

    Also there is this one, which I think I should be able to modify to do what I want:

    http://www.wooditwork.com/2011/08/11/adding-vmx-files-to-vcenter-inventory-with-powercli-gets-even-easier/

    Any hints or clues to push me in the right direction would be appreciated.



  • 2.  RE: List VMs in datastore that is not in inventory

    Posted Oct 26, 2015 02:49 PM

    In the script in Orphaned files and folders – Spring cleaning you can specify specific datastores to check.



  • 3.  RE: List VMs in datastore that is not in inventory

    Posted Oct 28, 2015 08:27 PM

    Wow Luc - you do answer the threads in here as fast as Alan said you would, in Barcelona :smileyhappy:

    Your script works great on shared datastores, however I can't get it to pick up orphaned files on singlehosts with local datastores.

    I removed the you line 42 : if($ds.Type -eq "VMFS" -and $ds.ExtensionData.Summary.MultipleHostAccess), but still nothing.



  • 4.  RE: List VMs in datastore that is not in inventory

    Posted Oct 28, 2015 09:54 PM

    By "singlehosts" do you mean standalone host not connected to any vCenter?





  • 5.  RE: List VMs in datastore that is not in inventory