Hi @Balayuvaraj M ,
you can try this to get the result in a CSV file:
$folder = "C:\Junk"
$outputFile = "C:\Junk\foldersize.csv"
Out-File -FilePath $outputFile -Encoding utf8 -InputObject "FolderName,Size"
$subfolders = Get-ChildItem $folder -Directory | Sort-Object
foreach ($folderItem in $subfolders) {
$subFolderItems = Get-ChildItem $folderItem.FullName -Recurse -Force -Depth 2 -File | Measure-Object -Property Length -Sum | Select-Object Sum
$folderItem.FullName + ”,” + “{0:N3}” -f ($subFolderItems.sum / 1MB) + ” MB” | Out-File -FilePath $outputFile -Append -Encoding utf8
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten