Skip to content

Instantly share code, notes, and snippets.

@MattCurryCom
Last active May 29, 2024 16:54
Show Gist options
  • Save MattCurryCom/2125deaf012eddf8d565bb1d5a935fba to your computer and use it in GitHub Desktop.
Save MattCurryCom/2125deaf012eddf8d565bb1d5a935fba to your computer and use it in GitHub Desktop.
$targetfolder='C:\Windows'
$dataColl = @()
gci -force $targetfolder -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$filesCount = (gci -recurse -force $_.fullname -File -ErrorAction SilentlyContinue | Measure-Object).Count
$dataObject = New-Object PSObject -Property @{
Folder = $_.fullname
SizeGb = ('{0:N3}' -f ($len / 1Gb)) -as [single]
filesCount=$filesCount
}
$dataColl += $dataObject
}
$dataColl | Export-Csv folder_size.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment