Link to home
Start Free TrialLog in
Avatar of JonBSS
JonBSS

asked on

Use PowerShell to get directory count, two sub folders deep.

I'm looking for a PoSh script that can check if a SubFolder exists 2 folders deep, if so, count the number of subfolders that are present.


Eg.

The basic structure should be
\\ServerName\Folder#\

We have a process where when documents are created, they are created under \\ServerName\Folder#\ in a \Temp\ directory and then flushed on process complete.  Unfortuantely, if the process does not complete, then the clean-up never happens

Eg.

\\ServerName\Folder1\
\\ServerName\Folder2\Temp\SubFolder1
\\ServerName\Folder2\Temp\SubFolder2
\\ServerName\Folder3\Temp\
\\ServerName\Folder4\Temp\SubFolder

Would return the following;
Nothing for \\ServerName\Folder1\
2 for \\ServerName\Folder2\
Nothing for \\ServerName\Folder3\
1 for \\ServerName\Folder4\
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JonBSS
JonBSS

ASKER

Thanks everyone.

And you're right oBdA, the example should have been formatted as //server/share/FolderX/Temp/SoOn