I am looking for a PS script that checks for a certain file type(.err) in a folder's sub-folders (depth -1) and if it finds at least one file with the required file type, prints only the sub-folder's name, without file patch or file name, e.g.:
[root folder]
[subfolder1]-has .err in it
[subfolder2]-doesn't have .err in it
[subfolder3]-doesn't have .err in it
[subfolder4]-has .err in it
[subfolder5]-has .err in it
Output:
[subfolder1]
[subfolder4]
[subfolder5]
I'm not good at PowerShell, so I only found how to list subfolder names which has .err files in it as many times as it has files inside.
(Get-ChildItem -Path C:\root -Depth 1 -recurse -filter *.err).DirectoryName | echo