简体   繁体   中英

Powershell script show count of subfolders

I'm going around in circles trying to run a powershell script which returns the sub-folder count of sub-folders in my root directory.

Eg Root directory C:\\temp Subfolders are C:\\temp\\1 and C:\\temp\\2 and each have x subfolders

I want to see the count of subfolders in C:\\temp\\1 and C:\\temp\\2 and if they are under C:\\temp\\1 or C:\\temp\\2.

So far I can only get a total subfolder count.

Pretty simple to do:

Get-ChildItem C:\Temp -Directory `
| Select-Object @{n='FullName';e={$_.FullName}},@{n='SubFolderCount';e={(Get-ChildItem $_.FullName -Recurse -Directory).Count}} `
| Format-Table -Autosize;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM