So I'm trying to combine #1 and #2 to get the sub-folder sizes and put into an out-gridview with folder name and MB/GB sizes. #3 works but it shows @name... vice just size mb/kb. looking for helping combining the two into one.
#1
Get-ChildItem -Path "C:\" -Recurse -Force -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum |
Select-Object @{Name="Size(kB)";Expression={("{0:N2}" -f($_.Sum/1kb))}},
@{Name="Size(MB)";Expression={("{0:N2}" -f($_.Sum/1mb))}},
@{Name="Size(GB)";Expression={("{0:N2}" -f($_.Sum/1gb))}} |
Out-GridView
#2
Get-ChildItem -path "C:\" -Directory -Recurse |
Select-Object FullName |
ForEach-Object -Process{New-Object -TypeName PSObject -Property @{Name =$_.FullName;Size = (Get-ChildItem -path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum ).Sum/1kb}} |
Select-Object Name, @{Name="Size(KB)";Expression={("{0:N2}" -f($_.Size))}}|
Out-Gridview
#3 - combine 1/2 and set variable path
#set path
$path = "c:\"
#GET Sizes sort MB/GB
Get-ChildItem -path "$path" -Directory -Recurse |
Select-Object FullName |
ForEach-Object -Process{New-Object -TypeName PSObject -Property @{Name =$_.FullName;Size = (Get-ChildItem -path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum)|
Select-Object Name,
@{Name="Size(MB)";Expression={("{0:N2}" -f($_.Sum/1mb))}},
@{Name="Size(GB)";Expression={("{0:N2}" -f($_.Sum/1gb))}}
}
}|
Out-GridView