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

Hi,

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?

Thanks
LVL 1
SAM2009Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

William FulksSystems Analyst & WebmasterCommented:
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.
0
SAM2009Author Commented:
Yes but I need something that give me that info for more than 2000 users. That's why I can't do it manually:-)
0
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
Something like this?

function Get-LnkTarget {
    Param (
        $FilePath
        )

    $sh = New-Object -ComObject WScript.Shell
    $sh.CreateShortcut($FilePath).TargetPath

    }

$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. :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Redefine Your Security with AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Check out our on-demand webinar to learn more about how AI can help your organization!

byt3Commented:
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
$Shortcuts
# to output to a CSV file use $Shorcuts | Export-Csv -Path DesktopShortcuts.csv

Open in new window

0
SAM2009Author Commented:
Thank you very much!
0
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
Glad to help. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.