Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Find and Delete a shortcut for all users

Is there a way to search through each users Desktop folder, for a particular shortcut link, and delete it? All computers are Windows 7.

0

Comments

3 comments
Date Votes
  • Hey Geoff,

    A quick foreach loop in PowerShell should take care of this,

    $files = Get-ChildItem C:\Users\*\Desktop\your_shortcut.lnk
    
    foreach ($file in $files)
    {
        Remove-Item $file -Force -WhatIf
    }
    

    You can run that on a target machine manually first to verify its doing what you would like. if it is, go ahead and remove the -WhatIF and you can run it as a PDQ Inventory Tool, or a PowerShell step in PDQ Deploy.

    -Josh

    0
  • Worked like a charm. Thank you so much Josh.

    0
  • I apologize for asking this, but I am still too new to PS scripts. I was wondering can this script be adapted to remove a Folder and all sub-folders  instead?

     

     

    0