Is there any way to get the folder size of a network drive using powershell

jack jones
jack jones used Ask the Experts™
on
what i am looking for is \\abc\
That is all the folders in \\abc and their respective folder size
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Engineer
Distinguished Expert 2017
Commented:
Below are two PowerShell scripts, the first one obtains the overall folder amount and the second one provides a breakdown of each subfolder (bear in mind if the folder is HUGE, this may take some time to obtain)...

$colItems = (Get-ChildItem "\\pmintl.net\rbsdata\SPA_BB01" -recurse | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB"

Open in new window



$startFolder = "\\pmintl.net\rbsdata\SPA_BB01"

$colItems = (Get-ChildItem $startFolder | Measure-Object -property length -sum)
"$startFolder -- " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB"

$colItems = (Get-ChildItem $startFolder -recurse | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
foreach ($i in $colItems)
    {
        $subFolderItems = (Get-ChildItem $i.FullName | Measure-Object -property length -sum)
        $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB"
    }

Open in new window


just change your server name and share name in it
Tom CieslikIT Engineer
Distinguished Expert 2017

Commented:
Best solution provided. No more other questions from author

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial