I want to get all files recursively from my drive and I'm using the enumeratefiles from system.io.directory as follows:
[System.IO.Directory]::EnumerateFiles("J:\","*","AllDirectories")|out-file -Encoding ascii $outputfile
foreach($line in select-string -Path $outputfile) {
# Some of the $line is the name of a hidden or system file
}
That works fine, however many lines contain hidden or system files.
I've used ennumeratefiles as the j: drive is very large and this function works fast and much better than the equivalent powershell cmdlets.
How can I test for these file types?
There is something on how to exlude these file types from enumeratefiles for c++ but nor for powershell and I don't know how to change the code for powershell:
c++ file hidden or system