Script to check huge folder size

Hello Guys,


Am using the below script line to check the directory folder Size.


$pth = "\\Share\MyFolder"

"{0:n2}" -f ((gci -path $pth -recurse | measure-object -property length -sum).sum /1gb)+" gb"



But this folder size is more than 200 GB, my script is taking very long time to show the result. 

the issue is after a wait for more than 40 minutes also i dint get output. 


(But the same script, poiting to folder with less size shows result immediately - confirmed to check the script works)



is there any other way i can make my script effecient to check huge folder size


Please assist.

  • Hi mohan93,

    I've added some code you can play with to give you an idea...

    $csvFolder = @"

    Folder Size
    C:\Temp\1 120000
    C:\Temp\2 202000
    C:\Temp\3 200000
    C:\Temp\4 300000
    C:\Temp\5 400000
    C:\Temp\6 330000
    C:\Temp\7 5000000
    C:\Temp\8 160000
    C:\Temp\9 2888000
    "@ | ConvertFrom-Csv -Delimiter "`t"

    $csvFolder | sort -Descending size | Select -First 5 | Out-GridView

    Once you have all of your folders sort them by size and then select the first 5 objects...



Reply Children