Hello all. I have build a package in the SCCM that creates a shortcut when deployed. I am using powershell script to accomplish that.
Param(
[parameter(Mandatory=$true)]
[ValidateSet("ADD","REMOVE")]
[String]$ShortcutType
)
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
Copy-Item $scriptDirectory\SupportFiles\atlas.ico -Destination C:\ProgramData\ -Recurse -Force
Function Push-OneStreamWebAll{
$Shell1 = New-Object -ComObject ("WScript.Shell")
$ShortCut1 = $Shell1.CreateShortcut("C:\Users\Public\Desktop\Service Catalog.lnk")
$ShortCut1.TargetPath ="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$ShortCut1.Arguments = "https://Google.com"
$ShortCut1.WorkingDirectory = "C:\Program Files (x86)\Microsoft\Edge\Application"
$ShortCut1.WindowStyle = 1
$ShortCut1.IconLocation = "C:\ProgramData\atlas.ico"
$ShortCut1.Save()
}
Function Remove-OneStreamWebShortCuts{
$REMTYPE = $ShortcutType -Replace "REMOVE",""
Remove-Item "$Env:Public\Desktop\Service Catalog.lnk" -Force
}
if ($ShortcutType -eq "ADD")
{Push-OneStreamWebAll}
if ($ShortcutType -like "REMOVE*")
{Remove-OneStreamWebShortCuts}
Shortcut is being created. However script for some reason does not copy the file in to the proper directory.