Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

NEW Copying files

Windows4life

New Member
Messages
3
Reaction score
0
Points
1
Hello all, i am running in to an issue and i am hoping that you guys can help me. I have a script that when i run it from a C:\temp works fine. It copies the .ico file to ProgramData folder and then script creates desktop shortcut with that icon. However when i deploy it via sccm .ico file does not get copied and desktop shortcut is empty.
Code:
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\Ares -Recurse -Force

Function  Push-OneStreamWebAll{
$Shell1 = New-Object -ComObject ("WScript.Shell")
$ShortCut1 = $Shell1.CreateShortcut("C:\Users\Public\Desktop\Ares Service Catalog.lnk")
$ShortCut1.TargetPath ="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$ShortCut1.Arguments = "https://ares.service-now.com/sp"
$ShortCut1.WorkingDirectory = "C:\Program Files (x86)\Microsoft\Edge\Application"
$ShortCut1.WindowStyle = 1
$ShortCut1.IconLocation = "C:\ProgramData\Ares\atlas.ico"
$ShortCut1.Save()

}


Function Remove-OneStreamWebShortCuts{
$REMTYPE = $ShortcutType -Replace "REMOVE",""
Remove-Item "$Env:Public\Desktop\Ares Service Catalog.lnk" -Force
}


if ($ShortcutType -eq "ADD")
{Push-OneStreamWebAll}

if ($ShortcutType -like "REMOVE*")
{Remove-OneStreamWebShortCuts}
 
Back
Top