VMware Cloud Community
seadl
Contributor
Contributor
Jump to solution

Search for ISO files in all NFS datastores bypassing the .snapshot folders

Hi,

Anyone has a tip on how to search all NFS datastores for an ISO files bypassing the ".snapshot*" folders.

What I had tried:

"dir -Recurse vmstores:\ -Include *.iso | select name,folderpath,lastwritetime,length||out-gridview"

But the above line does not skip the snapshot folders and it takes forever to scan due to the snapshot folders.

Any suggestions would be greatly accepted.

BR

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

There was a 'Select -First 1' in there for testing, I removed that.

Can you try again now ?


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

View solution in original post

Reply
0 Kudos
12 Replies
kunaludapi
Expert
Expert
Jump to solution

Try something like this

"dir -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -notmatch 'snapshot'} | select name,folderpath,lastwritetime,length||out-gridview"

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
Reply
0 Kudos
seadl
Contributor
Contributor
Jump to solution

It still goes and shows the .snapshot folders.

"dir -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -notmatch '.snapshot*'} | select name,folderpath,lastwritetime,length|out-gridview"

It is not skipping them.

Reply
0 Kudos
kunaludapi
Expert
Expert
Jump to solution

This should work

dir  -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -eq $true -and $_.name -notlike "*snapshot*"} | select name,folderpath,lastwritetime,length | out-gridview

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
seadl
Contributor
Contributor
Jump to solution

with the second reply it did not show anything (dir  -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -eq $true -and $_.name -notlike "*snapshot*"} | select name,folderpath,lastwritetime,length | out-gridview), it went for a long time and came back with error on one datastores saying it is not found and failed the script with no results.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this perhaps

Get-Datastore | Where {$_.Type -eq "NFS"} | %{
 
dir $_.DatastoreBrowserPath -Recurse -Exclude ".snapshot" | where {$_.Name -match ".iso$"}
}


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

Reply
0 Kudos
seadl
Contributor
Contributor
Jump to solution

Hi Luc,

Trying now, as it is about 600+ datastores it will take a while.

Will update with the results.

BR

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Perhaps it is wiser to test with just a few datastores ?

You can provide a datastorename (or mask) on the Get-Datastore cmdlet


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

Reply
0 Kudos
seadl
Contributor
Contributor
Jump to solution

Luc,

Did some tests on single data-store and my problem is as before, it goes through the ".snapshot" folders, that was exactly what I was trying from beginning to avoid.

I need to run the scan for *.iso files on the data-stores but skip the .snapshot and .dfm_snapshots as they take to long to be scanned.

BR

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

It looks like the Exclude switch doesn't really work for the datastore provider.

Try this vriation, it filters on the returned objects.

Get-Datastore | Where {$_.Type -eq "NFS"} | %{
 
dir $_.DatastoreBrowserPath -Recurse |
 
where {$_.Name -match ".iso$" -and $_.FolderPath -notmatch "\.snapshot|\.dfm_snapshots"} |
 
Select Name,FolderPath,LastWriteTime,Length
}


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

Reply
0 Kudos
seadl
Contributor
Contributor
Jump to solution

Cool,

The above worked on one data-store, but if I run without the data-store name it comes back finished and empty file.

I removed the data-store name to see if it runs on all the data-stores but did not for some reason.

BR

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

There was a 'Select -First 1' in there for testing, I removed that.

Can you try again now ?


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

Reply
0 Kudos
seadl
Contributor
Contributor
Jump to solution

Hi Luc,

This seems OK, it is going and skipping the .snapshots folders.

It is still in the process but I see that is good.

As there are about 600+ data-stores it is still going after 24hrs but it is OK.

Many thanks for your help, as always you are there to extend your kindness and knowledge.

Many thanks once again.

BR

Reply
0 Kudos