An easy worklet to create a desktop shortcut for everyone to a program. I have to use this to create a special Icon shortcut on desktops to our ERP software.
CODE:
$SourceFilePath = '{INSERT Direct Path Here - without brackets}'
$ShortcutPath = "C:\users\public\desktop\XXXXX.lnk"
$WScriptObj = New-Object -ComObject ("WScript.Shell")
$shortcut = $WscriptObj.CreateShortcut($ShortcutPath)
$Shortcut.WorkingDirectory = "{If Needed Insert Working Directory Here - without brackets}"
$shortcut.TargetPath = $SourceFilePath
$Shortcut.Arguments = "{IF Needed Insert Arguments for filepath - without brackets}"
$shortcut.IconLocation="{IF needed for custom Icon without brackets full path to icon}"
$shortcut.Save()
EXAMPLE:
$SourceFilePath = '\\xxx\xxx\xxx\xxx\xx\xxxxxx.exe'
$ShortcutPath = "C:\users\public\desktop\xxx.lnk"
$WScriptObj = New-Object -ComObject ("WScript.Shell")
$shortcut = $WscriptObj.CreateShortcut($ShortcutPath)
$Shortcut.WorkingDirectory = "\\xxx\xx\xx\xxx\xxx"
$shortcut.TargetPath = $SourceFilePath
$Shortcut.Arguments = "-xxx"
$shortcut.IconLocation="\\xxx\xxx\xxx\xxx\xxx\xxx.exe"
$shortcut.Save()