Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Script to get the total size of all subfolders in the current folder
- # Get the list of folders in the current folder
- $folders = Get-ChildItem -Directory
- # Preparing output file for reporting purposes
- $output = "Folder" + "`t" + "MB"
- Out-File -FilePath "./FolderSize.csv" -InputObject $output
- # Loop to get the size of each of the child folders
- foreach ($folder in $folders) {
- $size = "{0}" -f ((Get-ChildItem $folder -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1MB)
- $output = $folder.ToString() + "`t" + $size.ToString()
- Out-File -FilePath "./FolderSize.csv" -InputObject $output -Append
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement