Functions/Get-FolderSize.ps1
function Get-FolderSize { [CmdletBinding()] param ( [Parameter()] [string] $Path = "." ) $TotalSize = 0 $Files = Get-ChildItem $Path -Recurse -File $Files | ForEach-Object { # $_.Length $TotalSize += $_.Length } $TotalSize = $TotalSize / 1024 / 1024 / 1024 $TotalSize = [math]::Round($TotalSize, 2) $TotalSize = "$TotalSize GB" $Results = [PSCustomObject]@{ TotalSize = $TotalSize TotalItems = ($Files).Count } return $Results } |