FileSystemObject . .
function DirWithSize($path=$pwd)
{
$fso = New-Object -com Scripting.FileSystemObject
Get-ChildItem | Format-Table -AutoSize Mode, LastWriteTime, Name,
@{ Label="Length"; alignment="Left"; Expression={
if($_.PSIsContainer)
{$fso.GetFolder( $_.FullName).Size}
else
{$_.Length}
}
}
}
COM, dir, PowerShell, :
function DirWithSize($path=$pwd)
{
Get-ChildItem $path |
Foreach {if (!$_.PSIsContainer) {$_} `
else {
$size=0; `
Get-ChildItem $_ -r | Foreach {$size += $_.Length}; `
Add-Member NoteProperty Length $size -Inp $_ -PassThru `
}} |
Format-Table Mode, LastWriteTime, Name, Length -Auto
}