Is there a way to see a list of all the symbolic links that are active on a Windows machine?
I have accepted @JoachimOtahal’s answer as it works within a single second and I think provided what I needed when the questionw as asked.
Former accepted answer wrapped in timing code:
C:WindowsSystem32> cmd /E /C "prompt $T$$ & echo.%TIME%$ & dir /AL /S C: | find "SYMLINK" & for %Z in (.) do rem/ "22:01:17.00$06/05/2021 08:26 AM <SYMLINKD> All Users [C:ProgramData]06/14/2021 04:57 PM <SYMLINK> DEFAULTUSER_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigDEFAULT]06/14/2021 04:57 PM <SYMLINK> SAM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSAM]06/14/2021 04:57 PM <SYMLINK> SECURITY_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSECURITY]06/14/2021 04:57 PM <SYMLINK> SOFTWARE_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSOFTWARE]06/14/2021 04:57 PM <SYMLINK> SYSTEM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSYSTEM]06/14/2021 04:57 PM <SYMLINK> DEFAULTUSER_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigDEFAULT]06/14/2021 04:57 PM <SYMLINK> SAM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSAM]06/14/2021 04:57 PM <SYMLINK> SECURITY_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSECURITY]06/14/2021 04:57 PM <SYMLINK> SOFTWARE_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSOFTWARE]06/14/2021 04:57 PM <SYMLINK> SYSTEM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSYSTEM]05/22/2021 09:02 AM <SYMLINKD> All Users [C:ProgramData]06/14/2021 04:57 PM <SYMLINK> DEFAULTUSER_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigDEFAULT]06/14/2021 04:57 PM <SYMLINK> SAM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSAM]06/14/2021 04:57 PM <SYMLINK> SECURITY_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSECURITY]06/14/2021 04:57 PM <SYMLINK> SOFTWARE_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSOFTWARE]06/14/2021 04:57 PM <SYMLINK> SYSTEM_BASE [C:ProgramDataMicrosoftWindowsContainersBaseImages40caa4df-ced5-4c45-99a3-7e2bc561dafbBaseLayerFilesWindowsSystem32ConfigSYSTEM]02/26/2021 03:15 AM <SYMLINKD> Downloads [E:Downloads]22:01:38.69$ rem/
Accepted PS7 answer with giving different results within a second: https://superuser.com/a/1652788/68111
Solution:
$_.Linktype misses Symlinks. $_.Attributes misses Hardlinks. Junctions are listed in both properties. -Force is needed else hidden symlinks are skipped.Full working example which gets symlinks, junctions and hardlinks:
Get-ChildItem -Path "C:Windows","c:","$env:USERPROFILE" -Force | Where-Object { $_.LinkType -ne $null -or $_.Attributes -match "ReparsePoint" } | ft FullName,Length,Attributes,Linktype,Target
The output looks like this – in my case I made a junction just to show how it should look like. Be aware: PS still has a bug not showing the target of Symlinks, check this for more information: https://stackoverflow.com/questions/16926127/powershell-to-resolve-junction-target-path
PS D:> Get-ChildItem -Path "C:Windows","c:","$env:USERPROFILE" -Force | Where-Object { $_.LinkType -ne $null -or $_.Attributes -match "ReparsePoint" } | ft FullName,Length,Attributes,Linktype,TargetFullName Length Attributes LinkType Target -------- ------ ---------- -------- ------ C:Windowsbfsvc.exe 79360 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-b..vironment-servicing_31bf3856ad364e35_10.0.17763.1518_no...C:WindowsDfsrAdmin.exe 232960 Archive HardLink {C:WindowsWinSxSmsil_dfsradmin_31bf3856ad364e35_10.0.17763.529_none_86a482ce47ce0e6bDfsrAdmin.exe...C:Windowsexplorer.exe 4389168 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-explorer_31bf3856ad364e35_10.0.17763.1911_none_9f01b4994bb...C:WindowsHelpPane.exe 1072128 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-help-client_31bf3856ad364e35_10.0.17763.1911_none_b9659da9...C:Windowshh.exe 18432 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-htmlhelp_31bf3856ad364e35_10.0.17763.1697_none_15caed9d569...C:Windowsmib.bin 43131 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-snmp-mgmt-api_31bf3856ad364e35_10.0.17763.1_none_dc5249570...C:Windowsnotepad.exe 254464 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-notepad_31bf3856ad364e35_10.0.17763.1697_none_bc8f846641e0...C:Windowsregedit.exe 357888 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-registry-editor_31bf3856ad364e35_10.0.17763.1697_none_41a3...C:Windowssplwow64.exe 133632 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-printing-spooler-core_31bf3856ad364e35_10.0.17763.1697_non...C:Windowstwain_32.dll 64512 Archive HardLink {C:WindowsWinSxSwow64_microsoft-windows-w..ion-twaincomponents_31bf3856ad364e35_10.0.17763.1_none_...C:WindowsWindowsShell.Manifest 670 ReadOnly, Hidden, Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-shell32_31bf3856ad364e35_10.0.17763.1_none_5cef14c36a2559b...C:Windowswinhlp32.exe 11776 Archive HardLink {C:WindowsWinSxSwow64_microsoft-windows-winhstb_31bf3856ad364e35_10.0.17763.1_none_2420a29095f0ffc...C:WindowsWMSysPr9.prx 316640 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-mediaplayer-wmvsdk_31bf3856ad364e35_10.0.17763.1_none_96f1...C:Windowswrite.exe 11264 Archive HardLink {C:WindowsWinSxSamd64_microsoft-windows-write_31bf3856ad364e35_10.0.17763.1_none_5048bc153541494b...C:BackupPlatte Directory, ReparsePoint Junction {Volume{6072e7bc-2cae-11e9-b57a-bc5ff4e5c991}} C:Dokumente und Einstellungen Hidden, System, Directory, ReparsePoint, NotContentIndexed C:Programme Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorAnwendungsdaten Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorCookies Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorDruckumgebung Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorEigene Dateien Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorLokale Einstellungen Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorNetzwerkumgebung Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorRecent Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorSendTo Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorStartmenü Hidden, System, Directory, ReparsePoint, NotContentIndexed C:UsersAdministratorVorlagen Hidden, System, Directory, ReparsePoint, NotContentIndexed
Simple mod to dig down to what I was like in serach of (-and $_.Length -eq 1
) Powershell 7 + only:
PS > Get-ChildItem -Path "C:Windows","c:","$env:USERPROFILE" -Force | Where-Object { $_.LinkType -ne $null -or $_.Attributes -match "ReparsePoint" -and $_.Length -eq 1 } | ft FullName,Attributes,Linktype,TargetFullName Attributes LinkType Target-------- ---------- -------- ------C:Documents and Settings Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisApplication Data Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisCookies Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisDownloads Directory, ReparsePoint SymbolicLink {E:Downloads}C:UsersLouisiCloudDrive ReadOnly, Directory, Archive, ReparsePoint {}C:UsersLouisLocal Settings Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisMy Documents Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisNetHood Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisPrintHood Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisRecent Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisSendTo Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisStart Menu Hidden, System, Directory, ReparsePoint, NotContentIndexedC:UsersLouisTemplates Hidden, System, Directory, ReparsePoint, NotContentIndexed