May 31 2021 11:33 AM
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,
Jun 06 2021 04:25 AM
@Adrian Chirtoc You will need to add the following filter
where {$_.LinkType -notlike "SymbolicLink"}
Jun 12 2021 08:49 PM - edited Jun 12 2021 08:50 PM
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.
Jun 13 2021 04:37 AM