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

Re: Searching Multiple Datstores, Searching a root folder ".snapshot" for a folder matching "*_recent"

$
0
0

You can use the Datastore provider for this kind of searches.

Something like this

 

&{foreach($dcinGet-Datacenter){
   
foreach($datastoreinGet-Datastore-Location$dc){
       
New-PSDrive-Location$datastore-NameDS-PSProviderVimDatastore-Root'\'|Out-Null
       
$snap=Get-ChildItem-PathDS:\|
           
Where{$_.PSIsContainer-and$_.Name-eq".snapshot"}
       
if($snap){
           
$recent=Get-ChildItem-PathDS:\.snapshot|
               
Where{$_.PSIsContainer-and$_.Name-match"_recent"}
           
if($recent){
               
$result="Folder found"
            }
           
else{
               
$result=".snapshot\*_recent not found"
            }
        }
       
else{
           
$result=".snapshot folder not found"
        }
       
Remove-PSDrive-NameDS-Confirm:$false
       
$result|Select-Object@{N="Datacenter";E={$dc.Name}},
           
@{N="Datastore";E={$datastore.Name}},
           
@{N="Result";E={$_}}
    }
}}
|Export-Csvreport.csv-NoTypeInformation-UseCulture

Viewing all articles
Browse latest Browse all 219257

Trending Articles



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