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
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
Try something like this
"dir -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -notmatch 'snapshot'} | select name,folderpath,lastwritetime,length||out-gridview"
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.
This should work
dir -Recurse vmstores:\ -Include *.iso | where-object {$_.psiscontainer -eq $true -and $_.name -notlike "*snapshot*"} | select name,folderpath,lastwritetime,length | out-gridview
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.
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
Hi Luc,
Trying now, as it is about 600+ datastores it will take a while.
Will update with the results.
BR
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
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
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
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
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
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