Author Posts

October 21, 2017 at 6:25 am

I need to identify all folders that match \Foldername1\Foldername2 under \Users..

\users has multiple %USERNAME% directories under it.

Then delete all files under Foldername2

October 21, 2017 at 6:46 am

Ok you could use Get-ChildItem to find the directory and Remove-Item to delete it's contents.

October 21, 2017 at 7:07 am

THanks, but if I understand correctly Get-ChildItem only spans the current directory. I have to find "Folder3" under


Where each username is unique, and then delete the contents of all files in Folder3 for each user. I am also new to PS, so looking for examples ..


October 21, 2017 at 8:54 am

Something like this:

Get-ChildItem -Path C:\Users\ -Include folder1 -Recurse -Depth 2 -Directory | 
Get-ChildItem -Directory -Include folder2 | 
Get-ChildItem -Directory -Include folder3

Test the output and adjust accordingly; finally pipe the output to Remove-Item.

There are a few examples on the MS docs page.

October 21, 2017 at 4:48 pm

You can use wildcards in the path.

Get-ChildItem -path c:\users\*\folder1\folder2\folder3

Similarly you could use Resolve-Path.

Resolve-Path -Path c:\users\*\folder1\folder2\folder3