Published in Articles on by Michiel van Oosterhout ~ 1 min read

By default Windows 11 places a shortcut to the Microsoft Edge browser on the desktop of every user of the system. The shortcut file itself is stored in the hidden directory $Env:PUBLIC\Desktop. The Windows PowerShell script below will remove all shortcuts from that directory.

# The Desktop folder is hidden
Get-ChildItem -File -Filter "*.lnk" -Path "$Env:PUBLIC\Desktop" | ForEach-Object {
    $displayName = [System.IO.Path]::GetFileNameWithoutExtension($_)
    Write-Host "Removing shortcut [$displayName] from desktop... " -NoNewline
    Remove-Item -Path $_.FullName
    Write-Host "OK"
}

Additionally, if you want to hide $Env:PUBLIC you can execute this command in an elevated Windows PowerShell session to mark it with the hidden and system attributes: & attrib +s +h "$Env:PUBLIC".