Get-ChildItem cmdlet, the built-in WScript.Shell COM object, and Test-Path -LiteralPath. While a basic two-line command can list .lnk files whose targets appear missing, naive scripts routinely misidentify Windows Installer (MSI) advertised shortcuts, Microsoft Store app links, Control Panel items, and temporarily offline network shares as dead files. The workflow below works in Windows PowerShell 5.1 (preinstalled on all editions of Windows 10 and Windows 11) and PowerShell 7 or later, inspects any folder you choose in read-only mode, separates genuinely missing local targets from unreachable network paths and special system shortcuts, and lets you verify every match before sending unwanted .lnk files to the Recycle Bin.
Prerequisites and Compatibility Checks
Before scanning folders, confirm your PowerShell environment and permissions so Windows does not report false positives or skip system-wide shortcut folders:
- Use 64-bit PowerShell on 64-bit Windows: If you open
Windows PowerShell (x86)on a 64-bit PC, Windows File System Redirector translates%ProgramFiles%andC:\Windows\System32queries fromWScript.ShelltowardC:\Program Files (x86)andC:\Windows\SysWOW64. That redirection causes valid 64-bit application shortcuts to report as missing. Always run standard 64-bit PowerShell. - Standard user vs. administrator privileges: Scanning your personal Desktop, Documents, or per-user Start Menu folder works from a standard, non-elevated session. Scanning shared locations—such as the Public Desktop (
C:\Users\Public\Desktop) or the All Users Start Menu (C:\ProgramData\Microsoft\Windows\Start Menu)—requires an elevated session if you later choose to remove broken shortcuts from those directories. - Shortcut file types covered: Standard Windows file and folder shortcuts use the
.lnkextension. Internet shortcuts, Steam game launchers, and Epic Games shortcuts typically use the.urlplain-text format instead of.lnk; those point to web URLs or custom URI protocols (such assteam://rungameid/...) rather than local file paths and should be inspected separately. - Network and external storage state: Connect to your corporate VPN, wake any sleeping NAS devices, and plug in external drives you regularly use before running a scan if you want shortcuts pointing to those locations validated live.
Scan a Chosen Folder for Broken Shortcuts with PowerShell
The safest approach is a read-only audit script that classifies shortcuts by why their target failed validation rather than lumping every unusual shortcut together.
Step 1: Open a 64-bit PowerShell Session
Open the terminal interface for your operating system:
- Windows 11: Right-click the Start button (or press Win + X) and select Terminal (or Terminal (Admin) if you plan to inspect and clean
C:\Users\PublicorC:\ProgramData). Confirm the active tab runs Windows PowerShell or PowerShell rather than Command Prompt. - Windows 10: Right-click the Start button (or press Win + X) and select Windows PowerShell (or Windows PowerShell (Admin) for shared system folders).
Verify that you are running a 64-bit process on a 64-bit operating system by running:
(:ExpandEnvironmentVariables($RawTarget))::Is64BitProcess
If this returns True (or if you are on a 32-bit Windows 10 installation where (:ExpandEnvironmentVariables($RawTarget))::Is64BitOperatingSystem is also False), proceed to the next step. If it returns False on a 64-bit PC, close the window and launch Windows PowerShell without (x86) in the title.
Step 2: Choose the Folder Path to Inspect
Set $ScanFolder to the directory you want to audit. If you use OneDrive folder backup (Known Folder Move), your visible Desktop may live inside your OneDrive folder rather than C:\Users\<Username>\Desktop. Using (:ExpandEnvironmentVariables($RawTarget))::GetFolderPath('Desktop') automatically resolves your active Desktop path in both Windows 10 and Windows 11.
Run one of the assignments below—or specify any custom folder path of your choice:
# Option A: Your active user Desktop (handles OneDrive redirection automatically)
$ScanFolder = [Environment]::GetFolderPath('Desktop')
# Option B: Any custom folder path you want to inspect
# $ScanFolder = 'D:\Projects\Shortcuts'
# Option C: Your per-user Start Menu Programs folder
# $ScanFolder = [Environment]::GetFolderPath('Programs')
Confirm the resolved path exists before scanning:
Test-Path -LiteralPath $ScanFolder
PowerShell should return True.
Step 3: Run the Read-Only Shortcut Inspection Script
Copy and paste the script block below into your PowerShell window and press Enter. This command does not modify or delete any files. It reads every .lnk file inside $ScanFolder and its subfolders, expands environment variables if present, checks whether missing paths sit on disconnected drives or UNC shares, flags special shortcuts with empty or Windows Installer targets, and releases the COM object when finished.
$WshShell = New-Object -ComObject WScript.Shell
$MountedRoots = (Get-PSDrive -PSProvider FileSystem).Root
try {
$ShortcutReport = Get-ChildItem -LiteralPath $ScanFolder -Filter '*.lnk' -File -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
$ShortcutFile = $_
$Link = $WshShell.CreateShortcut($ShortcutFile.FullName)
$RawTarget = $Link.TargetPath
$ExpandedTarget = if ([string]::IsNullOrWhiteSpace($RawTarget)) {
''
} else {
}
$Status = 'Valid'
if ([string]::IsNullOrWhiteSpace($ExpandedTarget)) {
$Status = 'SpecialOrShellShortcut'
}
elseif ($ExpandedTarget -like "$env:SystemRoot\Installer\*") {
$Status = if (Test-Path -LiteralPath $ExpandedTarget) {
'AdvertisedInstallerShortcut'
} else {
'BrokenInstallerShortcut'
}
}
elseif ($ExpandedTarget.StartsWith('\\')) {
if (-not (Test-Path -LiteralPath $ExpandedTarget)) {
$Status = 'UnreachableUNCPath'
}
}
else {
$DriveRoot = [System.IO.Path]::GetPathRoot($ExpandedTarget)
if ($DriveRoot -and ($MountedRoots -notcontains $DriveRoot)) {
$Status = 'UnmountedDriveLetter'
}
elseif (-not (Test-Path -LiteralPath $ExpandedTarget)) {
$Status = 'MissingLocalTarget'
}
}
[PSCustomObject]@{
Status = $Status
ShortcutName = $ShortcutFile.Name
ShortcutPath = $ShortcutFile.FullName
TargetPath = $ExpandedTarget
Arguments = $Link.Arguments
WorkingDirectory = $Link.WorkingDirectory
LastWriteTime = $ShortcutFile.LastWriteTime
}
}
}
finally {
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($WshShell)
}
$ShortcutReport | Where-Object { $_.Status -ne 'Valid' } | Format-Table Status, ShortcutName, TargetPath -AutoSize
Step 4: Export or Inspect Detailed Results
Console tables truncate long paths on narrower displays. To view full paths, arguments, and shortcut locations for every non-valid item, format the output as a list or export it to a CSV file on your Desktop for review:
# View complete details in the console
$ShortcutReport | Where-Object { $_.Status -ne 'Valid' } | Format-List
# Optional: Export flagged items to a CSV report
$ReportFile = Join-Path -Path ([Environment]::GetFolderPath('Desktop')) -ChildPath 'Shortcut-Audit.csv'
$ShortcutReport | Where-Object { $_.Status -ne 'Valid' } | Export-Csv -LiteralPath $ReportFile -NoTypeInformation -Encoding UTF8
If PowerShell returns no output from the Where-Object { $_.Status -ne 'Valid' } filter, every .lnk file in $ScanFolder resolved to an existing target.
Review Disconnected Network Locations and Special Shortcuts Before Deleting Anything
Never pipe a raw list of unresolved shortcuts straight into Remove-Item. Each status category returned by the script above requires a different check before you decide a shortcut is obsolete:
MissingLocalTarget: The shortcut points to a mounted local volume (such asC:\), and the target executable, document, or folder does not exist at that path. These are genuine broken local shortcuts—typically left behind by manual program folder deletions, uninstalled portable apps, or moved documents. Check theArgumentsproperty before deleting: occasionally a launcher calls a relocated script passed throughArgumentswhile theTargetPathpoints to an old interpreter version.UnreachableUNCPath: The target begins with\\Server\Share.Test-PathreturnsFalsewhenever your PC is off the corporate network, disconnected from VPN, or blocked by expired SMB credentials—even when the shortcut works normally in the office. Test server reachability first (for example,Test-Connection ServerName -Count 1) before treating UNC shortcuts as dead.UnmountedDriveLetter: The target points to a drive letter (such asE:\orZ:\) that is not currently mounted in FileSystem drives. This happens with unplugged USB flash drives, external backup disks, unmounted VeraCrypt or BitLocker volumes, and mapped network drives that reconnect only when opened in File Explorer. Verify whether that drive letter belongs to removable media or a mapped share (Get-SmbMapping) before removing the shortcut.SpecialOrShellShortcut:WScript.Shellonly exposes standard file-system targets inTargetPath. When a.lnkfile points to a virtual Shell namespace item—such as a Control Panel applet, Devices and Printers, a packaged Microsoft Store (MSIX/AppX) app, or a virtual folder GUID—TargetPathcomes back completely empty even though double-clicking the shortcut works properly. LeaveSpecialOrShellShortcutitems intact unless you manually test the icon and confirm the underlying app was removed.AdvertisedInstallerShortcutandBrokenInstallerShortcut: Microsoft Office, enterprise MSI packages, and some CAD or creative suites create Windows Installer advertised shortcuts. Instead of pointing directly toC:\Program Files\..., theirTargetPathpoints to a cached stub icon insideC:\Windows\Installer\{GUID}\...so Windows Installer can repair missing files on launch. IfStatusisAdvertisedInstallerShortcut, the stub exists and the shortcut is healthy. OnlyBrokenInstallerShortcutindicates the cached installer stub itself is missing.
Optional Check: Inspect Plain-Text .url Shortcuts Separately
If your Desktop or folder also contains .url shortcuts with blank globe icons (common after uninstalling Steam, Epic Games, or browser web apps), WScript.Shell does not parse them the same way as .lnk files. You can list .url files and view their target URIs safely in read-only mode with Select-String:
Get-ChildItem -LiteralPath $ScanFolder -Filter '*.url' -File -Recurse -ErrorAction SilentlyContinue |
Select-String -Pattern '^(URL|IconFile)=' |
Select-Object Path, Line
Check any IconFile= lines that point to local .ico or .exe files that no longer exist, or URL= protocols (such as steam://) for launchers you have uninstalled.
Verify Flagged Shortcuts Before Cleanup
To verify that the script accurately detects missing targets—and to double-check any questionable shortcut before deleting it—confirm its state through File Explorer:
- Copy one
ShortcutPathreported asMissingLocalTargetfrom your PowerShell output. - Open its parent folder and highlight the shortcut in File Explorer directly from PowerShell:
explorer.exe /select,"C:\Path\To\Your\FlaggedShortcut.lnk" - Right-click the highlighted shortcut:
- Windows 11: Select Properties (or press Alt + Enter).
- Windows 10: Select Properties.
- On the Shortcut tab, check the Target box and click Open File Location.
- If the shortcut is genuinely broken, Open File Location either fails to find the path or Windows prompts you with a Problem with Shortcut dialog stating the item that the shortcut refers to has been changed or moved.
- If the Target box is grayed out and displays an application name rather than a file path, it is an advertised MSI or packaged Store shortcut—confirming why the PowerShell script separated
SpecialOrShellShortcutandAdvertisedInstallerShortcutitems fromMissingLocalTarget.
Alternate Method: Interactively Select Broken Shortcuts and Send Them to the Recycle Bin
Once you have reviewed the report, avoid Remove-Item, which bypasses the Recycle Bin and permanently erases files from disk. Instead, filter strictly to confirmed MissingLocalTarget items (or include other statuses only if you explicitly want them), pick the exact shortcuts to remove in an interactive Out-GridView window, and send them to the Windows Recycle Bin using the .NET Microsoft.VisualBasic.FileIO.FileSystem class.
Warning: Deleting shortcuts from shared directories (C:\Users\Public\DesktoporC:\ProgramData\Microsoft\Windows\Start Menu) removes them for every user account on the computer. In addition, if$ScanFolderis synced by OneDrive Backup, deleting shortcuts moves them to both your local Recycle Bin and your OneDrive cloud Recycle Bin across all synced Windows PCs. Review every row carefully before clicking OK.
- In the same PowerShell window where
$ShortcutReportis already populated, load theMicrosoft.VisualBasicassembly and open the interactive selection grid:
Code:Add-Type -AssemblyName Microsoft.VisualBasic $SelectedForRecycle = $ShortcutReport | Where-Object { $_.Status -eq 'MissingLocalTarget' } | Out-GridView -Title 'Hold Ctrl to select broken shortcuts to send to the Recycle Bin, then click OK' -PassThru - In the Out-GridView window that opens, review the
ShortcutName,ShortcutPath, andTargetPathcolumns. Click an item (or hold Ctrl and click multiple items) that you want to remove, then click OK in the bottom-right corner. Clicking Cancel or closing the window selects nothing. - Verify how many shortcuts you selected before deleting anything:
$SelectedForRecycle | Select-Object ShortcutName, ShortcutPath, TargetPath - Send only the selected
.lnkfiles to the Recycle Bin:
Code:foreach ($Item in $SelectedForRecycle) { if (Test-Path -LiteralPath $Item.ShortcutPath) { $Item.ShortcutPath, ) Write-Host "Recycled: $($Item.ShortcutPath)" } } - Re-run the
Test-Pathcheck against the recycled paths to confirm cleanup succeeded:
Every recycled shortcut should showCode:$SelectedForRecycle | ForEach-Object { [PSCustomObject]@{ ShortcutName = $_.ShortcutName StillExists = Test-Path -LiteralPath $_.ShortcutPath } }StillExistsasFalse.
Troubleshooting and Rollback
Valid 64-bit Program Shortcuts Report as MissingLocalTarget
- Cause: The scan ran inside a 32-bit PowerShell host (
Windows PowerShell (x86)or a 32-bit script runner), which redirectsC:\Program FilesandC:\Windows\System32lookups whenWScript.Shellreads the.lnkbinary structure. - Fix: Check
(:ExpandEnvironmentVariables($RawTarget))::Is64BitProcess. LaunchC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe(or 64-bitpwsh.exe) and run the scan again.
Shortcuts with Square Brackets [ ] in the Target Filename Fail Validation
- Cause: If you modify the script to use
Test-Path -Pathinstead ofTest-Path -LiteralPath, PowerShell treats[and]characters in folder or file names (such asReport [2026].xlsx) as wildcard character ranges and returnsFalseeven when the file exists. - Fix: Always keep
-LiteralPathonGet-ChildItem,Test-Path, andExport-Csvcalls so PowerShell evaluates every character literally.
Out-GridView Is Missing or Fails in PowerShell 7
- Cause:
Out-GridViewworks out of the box in Windows PowerShell 5.1, unless you are running a Server Core installation without desktop GUI components. In PowerShell 7,Out-GridViewrequires a graphical Windows session with .NET Windows Presentation Foundation support. - Fix: Run the script in Windows PowerShell 5.1 (
powershell.exe), or filter$ShortcutReportin the console usingWhere-Objectinstead ofOut-GridView.
UnauthorizedAccessException When Recycling Public Desktop or Start Menu Shortcuts
- Cause: Shortcuts displayed on your Desktop are a merged view of your personal Desktop folder and
C:\Users\Public\Desktop. Similarly, the Start Menu merges%AppData%\Microsoft\Windows\Start MenuandC:\ProgramData\Microsoft\Windows\Start Menu. Standard user accounts can read Public and ProgramData shortcuts, but modifying or recycling them requires administrator rights. - Fix: Open an elevated session (Terminal (Admin) in Windows 11 or Windows PowerShell (Admin) in Windows 10), set
$ScanFolderto(:ExpandEnvironmentVariables($RawTarget))::GetFolderPath('CommonDesktopDirectory')or(:ExpandEnvironmentVariables($RawTarget))::GetFolderPath('CommonStartMenu'), and repeat the audit and Recycle Bin steps.
Desktop Scan Misses Shortcuts Visible on Screen
- Cause: Either the missing icon lives in
C:\Users\Public\Desktop, or OneDrive folder backup moved your active Desktop folder while you manually typed$HOME\Desktop. - Fix: Check both
(:ExpandEnvironmentVariables($RawTarget))::GetFolderPath('Desktop')and(:ExpandEnvironmentVariables($RawTarget))::GetFolderPath('CommonDesktopDirectory'). To check whether OneDrive Desktop backup is active: - Windows 11: Open Settings > Accounts > Windows backup > Manage sync settings (or right-click the OneDrive cloud icon in the notification area and select Settings > Sync and backup > Manage backup).
- Windows 10: Right-click the OneDrive cloud icon in the notification area, select Settings, open the Backup (or Sync and backup) tab, and click Manage backup.
Rollback: Restore Deleted Shortcuts
- From the local Recycle Bin: Open Recycle Bin from the Desktop, locate the
.lnkfile (sort by Date Deleted if needed), right-click it, and click Restore. Windows returns the shortcut to its exact original folder path. - From OneDrive (if Desktop or Documents sync is enabled): If the local Recycle Bin was emptied on a OneDrive-backed folder, sign in to OneDrive on the web, select Recycle bin in the left navigation pane, select the deleted
.lnkfiles, and click Restore. - Recreating a missing MSI or Store app shortcut: If you permanently deleted a shortcut for an installed program with
Remove-Itembefore using the Recycle Bin method, repair the application rather than reinstalling from scratch. In Windows 11, go to Settings > Apps > Installed apps, click the three-dot menu next to the app, choose Modify or Advanced options, and run Repair. In Windows 10, go to Settings > Apps > Apps & features, select the application, click Modify or Advanced options, and select Repair.
Correction (November 29, 2026): Three PowerShell code blocks were incomplete as published. The 64-bit check in Step 1 was missing its command, the shortcut inspection script had an empty branch where environment variables in the target path should be expanded, and the Recycle Bin loop was missing the file deletion call that sends selected shortcuts to the Recycle Bin. All three blocks have been completed so the scripts run as described.