Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

Recursive public folder size

I need a bit of help with my code - I want to be able to recursively report the complete size for a public folder and all its child folders.
Here's what I have thus far, but it's currently spitting out results like:
0
0
10
750
0
12
etc...
I'm open to performing this another way, I just want it to match up with what is returned when I right-click on a public folder to get it's size properties...

function Get-PFFolderSizes {  
        param ($FolderPath)
        $Parent = Get-PublicFolder $FolderPath
        $Children = Get-PublicFolder $FolderPath -GetChildren
        
        foreach ($child in $Children) {
            $size = (Get-PublicFolderStatistics $child -Server $PFServer).totalitemsize.value.tokb()
            $ChildSizes += $size
            Get-PFFolderSizes $Child.identity.tostring()
        }
        return $ChildSizes
    }

$totalsize = Get-PFFolderSizes $folderpath

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Akhater
Akhater
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sirbounty

ASKER

Is line 11 supposed to be commented out?
Yes it is the return of the function is the full size of all the pfs,