Forum Discussion
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
- farismalaebIron Contributor
Adrian Chirtoc You will need to add the following filter
where {$_.LinkType -notlike "SymbolicLink"}
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.
- farismalaebIron ContributorCan you share the PowerShell Property members for the folder and SL.