ESXi

 View Only
  • 1.  Locate VMX files in datastores meant for Data disks

    Posted Jun 10, 2016 02:40 PM

    I was trying to locate VMX files in all our datastores, to see where we have System disks that need to be moved to more suitable datastores, for performance reasons.

    I ended up with a test connecting to one datastore I know there are VMX files in, and tried the following:

    PS vmstores:\VSPHERESERVER@443\VIT-ESX1\DATASTORE-ANN-01> Get-ChildItem -Recurse -Filter *.vmx

    But this does not give me any results. On the contrary, if I do this:

    PS vmstores:\VSPHERESERVER@443\VIT-ESX1\DATASTORE-ANN-01\VM001> Get-ChildItem -Recurse -Filter *.vmx | Sort-Object Name | Format-Table -AutoSize

       Datastore path: [DATASTORE-ANN-01] VM001

           LastWriteTime Type Length Name

           ------------- ---- ------ ----          

    14.05.2016     16:39 File   3662 VM001.vmx

    I don't see why this happens, but I was wondering if anybody has this experience, or has other ways to do this.

    Running this on 200-250 datastores is VERY time-consuming, I tested with three datastores, and I had to stop it, because it took quite a long time



  • 2.  RE: Locate VMX files in datastores meant for Data disks

    Posted Jun 10, 2016 04:58 PM

    Ignore the word wrapping each command line is purely a single line of code. Found these results scattered in different areas of the Forums, so much of the results can be found if you do a short search on things like "Search files on Datastores" or something along those lines.

    Something like this may work for you. It will take a while for it to collect all the data though if you have a lot of folders and VMs to sort through and depending on the size of your storage solution:

    To search any datastore for VMX but not local storage

    dir -recurse (get-datastore * | where {$_.Name -notlike "*local*"}).datastorebrowserpath -Include "*.vmx" | select Name,DatastoreFullPath,LastWriteTime

    This just checks all datastores for VMX

    dir -recurse (get-datastore *).datastorebrowserpath -Include "*.vmx" | select Name,DatastoreFullPath,LastWriteTime

    To search a specific datastore for VMX

    dir -recurse (get-datastore "datastorename").datastorebrowserpath -Include "*.vmx" | select Name,DatastoreFullPath,LastWriteTime

    To export the results to a CSV or something just add a piped statement

    dir -recurse (get-datastore *).datastorebrowserpath -Include "*.vmx" | select Name,DatastoreFullPath,LastWriteTime | Export-Csv c:\Temp\VMXFiles.CSV -Append -NoTypeInformation -Confirm:$false

    Hope this helps in your efforts!!