Processing symbolic links and junctions safely in PowerShell

PowerShell's Get-ChildItem -Recurse will recurse into symbolic links and junctions, unless prohibited by ACLs. This can easily result in pseudo-infinite loops where PowerShell returns paths such as C:\Users\All Users\Application Data\Application Data\Application Data. The C:\Users directory is particularly prone to such problems, as it contains both a symbolic link and a junction:

The following function Find-Files – both in name and behavior inspired by the Unix find program – avoids this problem as it does not recurse into symbolic links or junctions:

Find-Files.ps1