Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 230656

Re: way to find vm which are not removed disk

$
0
0

If you only need a report, you can do like this (I made some changes to your script).

 

$unregistered= @()

 

foreach($Datastorein (Get-Datastoreclusterxxxx|Get-Datastore)) {

# Collect .vmx paths of registered VMs on the datastore

  $registered= @{}

  Get-VM-Datastore$Datastore|%{

    $_.Extensiondata.LayoutEx.File |where {$_.Name -like"*.vmx"} |%{$registered.Add($_.Name,$true)}}

# Set up Search for .VMX Files in Datastore

  New-PSDrive-NameTgtDS-Location$Datastore-PSProviderVimDatastore-Root'\'|Out-Null

  $unregistered+= (@(Get-ChildItem-PathTgtDS:-Recurse|

    where {$_.FolderPath -notmatch".snapshot"-and$_.Name -like"*.vmx"-and!$registered.ContainsKey($_.DatastoreFullPath)} |

    SelectDatastoreFullPath))

  Remove-PSDrive-NameTgtDS

}

$unregistered|Export-Csvc:\temp\vm-unregister.csv-NoTypeInformation-UseCulture

 


Viewing all articles
Browse latest Browse all 230656

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>