This is used to get the file count, subdirectory count and folder size for the path specified. The output will show the current folder stats unless you specify the "AllItemsAndAllFolders" property. Since this uses Get-ChildItem as the underlying structure, this supports local paths, network UNC paths and mapped drives. Furthermore it was developed to work also in PowerShell constrained language mode.
PARAMETER Recurse
'Using this parameter will drill down to the end of the folder structure and output the filecount, foldercount and size of each folder respectively.'
PARAMETER AllItemsAndAllFolders
'Using this parameter will get the total file count, total directory count and total folder size in MB for everything under that directory recursively.'
PARAMETER Attrib
'–Attrib : This parameter gets files and folders with specified attributes. When you use this parameter, you can specify a complex combination of attributes.'
You cannot use space between an operator and its attributes, but space is permitted before commas. The Attribute parameter supports the following attributes.
Archive | Offline | Compressed| ReadOnly | Device | ReparsePoint | Directory | SparseFile | Encrypted | System | Hidden | Temporary | Normal | NotContentIndexed
Following Operators can be used to combine attributes:
! = NOT
+ = AND
, = OR
Following abbreviations are used for attributes:
D: Directory
A: Archive
H: Hidden
R: Read-Only
S: System
EXAMPLES
Get-DirectoryTreeSize -Path c:\temp -Attrib A,D,H,Normal -AllItemsAndAllFolders -Scale MbTotalFolderSize | TotalFileCount | Path | TotalDirectoryCount |
---|---|---|---|
258,68Mb |
1025 |
C:\Temp\ |
523 |
Get-DirectoryTreeSize -Path C:\Temp\ -Attrib a,h,s -Scale Mb | select path,directorycount,filecount,foldersize
Path | DirectoryCount | FileCount | FolderSize |
---|---|---|---|
C:\Temp\ |
1 |
30 |
258,68Mb |
Get-DirectoryTreeSize -Path C:\Temp\ -Attrib a,h,d -Recurse -Scale Kb | select path,directorycount,filecount,foldersize
Path | DirectoryCount | FileCount | FolderSize |
---|---|---|---|
C:\logs\ |
5 81 |
622,76 Kb |
|
.\MSI |
1 41 |
34.084,91 Kb |
|
.\MSU |
0 0 |
Empty |
|
.\PatchMgmt |
0 1 |
16,25 Kb |
|
.\PKGDB |
0 0 |
Empty |
|
.\Trace |
0 33 |
552,52 Kb |
|
.\MSI\Enterprise-Erstinstallation_10.7.0-3299.1.log |
0 |
22 |
5.273,51 Kb |