Powershell Script To Mass Change Shortcut Path

I have been looking at getting a script together for a while to mass change some shortcuts we have on our file server to point to a different location. After some research, and some playing around I found a really easy way to do this in Powershell:

# Call wscript com object
$shell = new-object -com wscript.shell

# Recurse through directories for .lnk files
dir "I:\" -filter *.lnk -recurse | foreach {
$lnk = $shell.createShortcut($_.fullname)
$oldPath= $lnk.targetPath

# If match text, perform operation
if($oldpath -match "\\serverold\share1")
write-host "Match: " + $_.fullname
remove-item $_.fullname
$lnknew = $shell.createShortcut($_.fullname)
$lnknew.targetPath = "`"\\newserver\share1`""
$lnknew.IconLocation = "%SystemRoot%\system32\SHELL32.dll,4"
Write-Host "End..."


  • Andy commented on August 9, 2012


    only Problem is…. Link before \\server1\C$\temp -> Link after \\server2\
    so not really the perfect solution.

  • Edgar commented on December 15, 2012

    Thank you, it has put me in the right track!

  • HoseaSmall commented on February 3, 2018

    I have checked your website and i’ve found some duplicate content,
    that’s why you don’t rank high in google, but there is a
    tool that can help you to create 100% unique articles, search for:
    Boorfe’s tips unlimited content

Leave a Reply

Your email address will not be published. Required fields are marked *