Hello @R99photography,
Thank you for your question.
You can do this using the script below inside PowerShell
cls
$NetLocName = $args[0]
$NetLocTargetPath = $args [1]
if (!(test-Path $NetLocTargetPath)) # -pathType container))
{
write-Host "Problem with entered target path:" $ NetLocTargetPath
write-Host "Exiting..."
exit
}
$ const_NETHOOD = 0x13
$oApp = new-Object -with Shell.Application
$oShell = new-Object -with Wscript.Shell
$NetHood = ($oApp.Namespace($const_NETHOOD)). Self.Path
$NetLocLocalPath = "$NetHood \$NetLocName"
if (!(test-Path $NetLocLocalPath -pathType container))
{
new-Item $NetLocLocalPath -type directory -force
attrib "$NetLocLocalPath" + R
}
if (! (test-Path "$NetLocLocalPath \ Desktop.ini" -pathType leaf))
{
$oFile = new-Item "$NetLocLocalPath \ Desktop.ini" -file type -force
add-Content $oFile "[.ShellClassInfo]"
add-Content $ oFile "CLSID2 = {0AFACED1-E828-11D1-9187-B532F1E9575D}"
add-Content $oFile "Flags = 2"
attrib "$NetLocLocalPath \ Desktop.ini" + H + S -A
}
if ((test-Path "$ NetLocLocalPath \ target.lnk" -pathType leaf))
{
$ oLnk = $ oShell.CreateShortcut ("$ NetLocLocalPath \ target.lnk")
$OldLnk = $oLnk.TargetPath
if ($OldLnk -ne $NetLocTargetPath)
{
$oLnk.TargetPath = $NetLocTargetPath
$ oLnk.Save()
}
}
other
{
$ oLnk = $ oShell.CreateShortcut ("$ NetLocLocalPath \ target.lnk")
$oLnk.TargetPath = $NetLocTargetPath
$ oLnk.Save()
}
or you can do this via GPO using the instructions below:
1) Create a folder:
GPO> User Configuration> Preferences> Windows Settings> Folder Paths :% NetPlacesDir% \ <share name> You may want to set the "Remove this item when no longer applied" checkbox in the "common tab"
2) Create a link:
GPO> User Configuration> Preferences> Windows Settings> Shortcut Name : <share name> \ target Destination type: File system Object location : My network Locations Destination path: \ server \ shares \ share.
3) Create Desktop.ini:
GPO> User Configuration> Preferences> Windows Settings>
File path of Ini files :% NetPlacesDir% \ <share name> \ Desktop.ini
Section name: .ShellClassInfo
Property name: CLSID2
Property Value: {0AFACED1-E828-11D1-9187-B532F1E9575D}
File path:% NetPlacesDir% \ <share name> \ Desktop.ini
Section name: .ShellClassInfo
Property Name: Flags
Property Value: 2
If the answer was helpful, please don't forget to vote up or accept as an answer, thanks.
Yours sincerely,
Samuel L