Recursively find all Symbolic Links with PowerShell

logo-horizontalI just started using SyncThing, and have found it to be a powerful way to keep the files on my various personal computers in sync. I like this solution. I sync on my own private network, avoiding privacy-risking cloud services. I discovered fairly quickly that SyncThing will give warning messages about any symbolic links it encounters, letting you know it won’t try to sync those. In my case, this was shortcut folders like My Videos and My Music in my ~/Documents folder.

powershellThis PowerShell script will let you discover any such symbolic links recursively under a given folder:

if (-not (Test-Path $Path -PathType 'Container'))
  throw "$($Path) is not a valid folder"
$Current=Get-Item .
function Test-ReparsePoint($File) {
  if ([bool]($File.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
  } else {
cd $Path
# Recurse through all files and folders, suppressing error messages.
# Return any file/folder that is actually a symbolic link.
ls -Force -Recurse -ErrorAction SilentlyContinue | ? { Test-ReparsePoint($_) }
cd $Current

The function in this script was derived by from the answer given by Keith Hill at If you save the above script as ~/scripts/FindSymLinks.ps1, here is what a sample session looks like:

PS C:\Users\Dad\scripts> .\FindSymLinks.ps1 ..\Documents
    Directory: C:\Users\Dad\Documents
Mode               LastWriteTime     Length Name
----               -------------     ------ ----
d--hs       10/24/2009   2:09 PM           My Music
d--hs       10/24/2009   2:09 PM           My Pictures
d--hs       10/24/2009   2:09 PM           My Videos

Automatically Delete TEMP Folder in Windows (no installs required)

When I use Linux, I love that anything I place in /tmp will be wiped when I shut the system down. Windows, out of the box, doesn’t do this for your %TEMP% folder. Google this, and you’ll find many people advising to install one free tool or another. I am very wary of unnecessary installations on my Windows machines. The advice given here at requires no installations. It was meant for Windows XP Pro, but I found today that it worked just as well on my Windows 7 Professional system.

Unlike the fixed /tmp location in Linux, Windows determines the value of %TEMP% and create that folder dynamically at every login. Firefox doesn’t seem to accept %TEMP% as a valid value in on about:config. Therefore, I

  1. keep a sidebar shortcut to %TEMP% in Windows Explorer, and
  2. select “Always ask me where to save files” in the Downloads section of the General tab of the Options dialog.

That way, it is easy for me to select my %TEMP% folder when downloading in Firefox, as well to access it from Windows Explorer.