Forum Discussion

Adrian Chirtoc's avatar
May 31, 2021

Measure Folder size containing SymbolicLink

Hello,

I have the fallowing problem. I want to get the size of folders but some of them have subfolders that are SymbolicLink to other folders. How do I easily exclude them?

function GetFolderSize($path){

$total = (Get-ChildItem $path -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property length -Sum -ErrorAction SilentlyContinue).Sum

if (-not($total)) { $total = 0 }

$total

}

 

Complicated way i was thinking to check all the folders, and calculate only the ones that are not SymbolicLink. But this will not be a easy way.

 

Thank you,

3 Replies

    • Adrian Chirtoc's avatar
      Adrian Chirtoc
      MCT

      This at me did not skip the files inside the folder that had the SymolicLink as they do not have this property. Only the folder has it.

      • farismalaeb's avatar
        farismalaeb
        Iron Contributor
        Can you share the PowerShell Property members for the folder and SL.

Resources