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.

Desktop Icon Search

Anyone have a package/script that scans all the user profiles for a desktop shortcut ?

Before I took over they just manually created desktop icons instead using GPO or any managing software. I'd like to scan all the computers for an old Icon.  It could be named a few different things so if there is anyway to include  "like"  than include a few different names that would be amazing. 

1

Comments

5 comments
Date Votes
  • We have a package that removed desktop shortcuts from all profiles. Our case might be a little different from yours in that our shortcuts were url shortcuts to a web based timekeeping system so they ended in .url instead of .lnk, but that concept should be the same.

    In my case the PDQ package is just calling a batch file. The batch file then iterates through all profiles looking for the shortcuts. In my batch file there are three different shortcuts it's looking for. Here is the script from the batch file:

    for /f %%a in ('dir /B /AD C:\Users') do (
        if exist "C:\Users\%%a\Desktop\Kronos Workforce Central.url" del /F /Q "C:\Users\%%a\Desktop\Kronos Workforce Central.url"
        if exist "C:\Users\%%a\Desktop\Quick TimeStamp.url" del /F /Q "C:\Users\%%a\Desktop\Quick TimeStamp.url"
        if exist "C:\Users\%%a\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Quick TimeStamp.url" del /F /Q "C:\Users\%%a\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Quick TimeStamp.url"
    )

    Not sure about the name variations you mention, but if there's a commonality, hopefully you can wildcard it.

    1
  • This is a Powershell script that I use to search for a shortcut and then delete it.  In this case, it is looking for an example.lnk file in desktop folder for each user's profile.

    Get-ChildItem C:\Users\*\Desktop\Example*.lnk | Remove-Item

    1
  • That looks a lot easier than my script. I am learning more and more how much powershell can do, but am nowhere near fluent in it.

    0
  • Thanks Heath and Gary!  I think Heath's will work just fine. 

    0
  • Thought I'd post a solution that worked for me with PDQ Inventory and Powershell. 

    Reference URL: http://keithbloom.blogspot.com/2009/06/powershell-delete-files-containing.html

    My goal was to search through all user profiles (Desktop and Favorites) for any .url (normal shortcut) or .website (pinned site) files on remote computers that contained a specific domain pattern and delete them.

    I ended up creating an Inventory powershell tool to run the script below. 

    Tool settings:

    Run Type: Remote

    Run As: Local System

    Powershell: 

    $list = gci C:\users\*\Desktop\* -include *.url, *.website -recurse | select-string -pattern "sub.domain.com"
    $list | foreach { rm $_.Path }
    $list2 = gci C:\users\*\Favorites\* -include *.url, *.website -recurse | select-string -pattern "sub.domain.com"
    $list2 | foreach { rm $_.Path }
    0