none
How to list all .URL shortcuts on multiple computers desktops RRS feed

  • Question

  • I've been searching to find a Powershell script that polls a list of computer names and then returns a list of the .URL shortcuts along with their targets from the logged in users desktop.

    Does anyone know if there is one out there or at least point me in the right direction?

    Thanks

    Thursday, January 9, 2014 8:09 PM

Answers

  • There are several things you will need to piece together.

    1. Get a list of computer names.
    2. Recurse through the user directories on each computer, looking for .url files.
    3. Open each shortcut file to see where it's pointing, and write this data somewhere.

    The larger question is, why do you need to do it? Group Policy has allowed admins to populate users' favorites for a number of years now.

    Bill

    Thursday, January 9, 2014 10:57 PM
    Moderator

All replies

  • Hi,

    You can check the repository:

    http://gallery.technet.microsoft.com/scriptcenter

    It's highly unlikely that you'll find a script that will totally meet your requirements without any tweaking though.


    Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)

    Thursday, January 9, 2014 8:12 PM
  • I've searched through it with not much luck. I'll continue..
    Thursday, January 9, 2014 8:36 PM
  • There are several things you will need to piece together.

    1. Get a list of computer names.
    2. Recurse through the user directories on each computer, looking for .url files.
    3. Open each shortcut file to see where it's pointing, and write this data somewhere.

    The larger question is, why do you need to do it? Group Policy has allowed admins to populate users' favorites for a number of years now.

    Bill

    Thursday, January 9, 2014 10:57 PM
    Moderator
  • Bill.. Got it.. To answer your question, we have about 300 users that have a bunk url shortcut that is causing problems when launching. Mgmt wants to find all the users that have this URL and then remove it so they can push out a valid URL via GPO. They asked me to automate this as they don't want to email every user (most likely because of embarrassment)

    I am usually pretty good at piecing together scripts to do what is needed to do but this one I'm drawing a blank on. 

    Friday, January 10, 2014 12:19 AM
  • Unfortunately, this isn't a script on demand forum. I gave you an outline of an approach you could use, but writing the actual script is up to you. If this is critical to your business, I recommend hiring a qualified consultant.

    Bill

    Friday, January 10, 2014 2:44 AM
    Moderator
  • $strComputer = Get-Content C:\ps\test.txt
    
    function Get-DesktopShortcuts
    {
        $Shortcuts = Get-ChildItem -Recurse ~\desktop\ -Include *.url
        $Shell = New-Object -ComObject WScript.Shell
    
    foreach ($computer in $strComputer)
    {	
    	 foreach ($Shortcut in $Shortcuts)
        {
            $Properties = @{
    			Computer = $computer.Name
                ShortcutName = $Shortcut.Name
                Target = $Shell.CreateShortcut($Shortcut).targetpath
            }
    
    
            New-Object PSObject -Property $Properties
        }
    
    
        [Runtime.InteropServices.Marshal]::ReleaseComObject($Shell) | Out-Null
    }
    }
    
    $Output = Get-DesktopShortcuts
    $Output
    
    $Output | Export-Csv C:\ps\shortcut.csv
    This is what I've put together but seems to only show a single url for each computer even though I know there are multiple .url files on the desktop for each computer. Plus it is outputting only google.com shortcuts. Hmmm
    • Edited by TheBigChris Wednesday, January 15, 2014 8:13 PM
    Wednesday, January 15, 2014 8:00 PM