I have a UWP app I created and want to use powershell to create a shortcut on the desktop.
Creating a shortcut is easy for an exe
$TargetFile = \"\\
To prevent your shortcut from having the standard Explorer icon. Change the $Shortcut.TargetPath
like this :
$TargetPath = "shell:AppsFolder\Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUi"
$ShortcutFile = "$Home\Desktop\Cortana.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()
This way the shortcut will have the same icon as the application.
You can also create a shortcut *.url
via URI (if the application in question supports it) (https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-default-app) :
$TargetPath = "ms-cortana:"
$ShortcutFile = "$Home\Desktop\Cortana.url"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()