Is there a way to list all [b]shortcuts target[/b] on each desktop users computers?

SAM2009 used Ask the Experts™

Is there a way to list all shortcuts target on each desktop users computers?

I need to know what user has what shortcut point to where.

Any script or cmd?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
William FulksSystems Analyst & Webmaster

If you browse to their desktop you can change the view to display the Link Target.

Right click in the white space above the file icons where it says Name, Date Modified, etc, then it will show you a list of other columns to add. Click More then scroll down to the "Link Target" option and select it. It will then show you were stuff points.


Yes but I need something that give me that info for more than 2000 users. That's why I can't do it manually:-)
Senior Network Consultant / Engineer
Something like this?

function Get-LnkTarget {
    Param (

    $sh = New-Object -ComObject WScript.Shell


$DesktopPath = (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders').desktop

$DesktopShortcuts = GCI $DesktopPath *.lnk | %{$_ | select *, @{n='ShortcutTarget';e={Get-LnkTarget -FilePath $_.FullName}},@{n="username";e={$env:USERNAME}}}

Open in new window

In addition to all the regular attributes, it add the "ShortcutTarget" and "Username" properties. You can then export that to a CSV on the network.
Run is as a logon or logoff script.

Once you have the results you can parse all the CSV files with the tool of your choice. :)
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Here's another option:

## Use WMI to get a list of user profiles (the list includes system accounts). We don't get usernames,
## so filter out System accounts by number of chunks in the SID and only list accounts that have the
## desktop folder
$UserProfiles = Get-WmiObject -Class Win32_UserProfile | Select-Object -Property SID,LocalPath | Where-Object {($_.SID -split "-").Count -ge 5 -and (Test-Path -Path "$($_.LocalPath)\Desktop")};

## for each profile, get the shortcuts in the desktop folder and determine the targetpath of each
$Shortcuts = @(); #variable to store the data found
foreach ($UserProfile in $UserProfiles) {
    $ProfilePath = $UserProfile.LocalPath;
    $DesktopPath = "$ProfilePath\Desktop"
    foreach ($ShortcutPath in (Get-ChildItem -Path $DesktopPath -Filter *.lnk).FullName) {
        #get the target path using a COM Object
        $TargetPath = (New-Object -ComObject WScript.Shell).CreateShortcut($ShortcutPath).TargetPath;
        #add object to the shortcuts variable
        $Shortcuts += New-Object -TypeName psobject -Property @{
            Profile = $ProfilePath;
            ShortcutName = (Get-Item -Path $ShortcutPath).Basename;
            ShortcutPath = $ShortcutPath;
            TargetPath = $TargetPath
## output the objects in the shortcut variable
# to output to a CSV file use $Shorcuts | Export-Csv -Path DesktopShortcuts.csv

Open in new window


Thank you very much!
Jeremy WeisingerSenior Network Consultant / Engineer

Glad to help. :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial