for hours I've been struggling to get powershell to do the following:
Use the base directory C:\Users and go recursively through all folders excluding the AppData folder of each user dir and also excluding the users named:
$exclude = @('Administrator', 'All Users', 'Default', 'Default User', 'Public', 'TEMP')
The output should then list me all files with certain extensions.
UPDATE
How can I add these additional statements to the output?
Get-Childitem $Path -Include $extensions -Recurse -Force -ErrorAction SilentlyContinue |
Select Name,Directory,@{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}},CreationTime,LastAccessTime, Length
2. Update
what is the right way to set a pattern in order to match with remote hosts of the network?
$exclude_pattern = "\\hostname\\c$\\Users\\(" + ($exclude -join '|') + ")";
If I replace hostname with my computer name it doesn't match. I don't see where the line is wrong compared to the local pattern:
C:\\Users\\(Administrator|All Users|Default|Default User|Public|TEMP|Saargummi|dvop|leasingadmin|cenit|cadop|[^\\]+\\AppData)
\\hostname\\c$\\Users\\(Administrator|All Users|Default|Default User|Public|TEMP|Saargummi|dvop|leasingadmin|cenit|cadop|[^\\]+\\AppData)
3. Update
Is there a smart way to include extensions which are written in upper case? Or do I need to write '.wav', '.WAV' for example?