PSFolderSize
PSFolderSize copied to clipboard
Include files in the list
The report is incomplete since it doesn't include the size of the files in $BasePath.
get all of the folder information , but do it for files in $BasePath
#Get folder info / sizes
$folderSize = Get-Childitem -Path $BasePath -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum -ErrorAction SilentlyContinue
#We use the string format operator here to show only 2 decimals, and do some PS Math.
$folderSizeInMB = "{0:N2} " -f ($folderSize.Sum / 1MB)
$folderSizeInGB = "{0:N2} " -f ($folderSize.Sum / 1GB)
#Here we create a custom object that we'll add to the array
$folderObject = [PSCustomObject]@{
FolderName = '"files"'
'Size(Bytes)' = $folderSize.Sum
'Size(MB)' = $folderSizeInMB
'Size(GB)' = $folderSizeInGB
}
#Add the object to the array
$folderList.Add($folderObject) | Out-Null
Thank you for a very useful tool.
Good morning! Glad the tool has been useful for you. I will be working on the two issues you have opened, and roll them into my next version release that includes the other open ones as well.