How to make shortcut a powershell script

Hey!

Hope to get help in here. I’ll make a shortcut in the powershell deployment toolkit that points to a powershell script. I don’t get it right when I set execution policy bypass. I want it to be like this in the shortcut that is created:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "\SERVERNAME\Program\Viva\VivaUpdate_Basic__IBM-map-PS.ps1"

But not with “SERVERNAME”. I’ll replace that later. Don’t want to print with this in here. The string I put in the Deployment script is this line:

New-Shortcut -Path “$envProgramData\Microsoft\Windows\Start Menu\Programs\Viva\Viva.lnk” -TargetPath “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File” ‘"\SERVERNAME\Program\Viva\VivaUpdate_Basic__IBM-map-PS.ps1"’ -IconLocation “$dirfiles\Update_Shortcut\Viva_icon.ico” -Description ‘Viva’ -WorkingDirectory "\SERVERNAME\Program\Viva"

What happens then is that it puts double “” in front of the path to powershell. Here’s what it looks like in the shortcut created by the Deploymet toolkit script:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File" "\SERVERNAME\Program\Viva\VivaUpdate_Basic__IBM-map-PS.ps1"

So before "C:\ this is created and after Bypass -File". This can not be included, then it may not work. Does anyone have a string that works where it excludes these double " "?
I have tried to remove and replace a bit in the Deploy script. But nothing seems to work.

Grateful for answers

Sincerely

John R.

Try this:

$ShortcutArguments = " -ExecutionPolicy ByPass -File “” \\SERVERNAME\Program\Viva\VivaUpdate_Basic__IBM-map-PS.ps1"" -WindowStyle Hidden"

New-Shortcut -path “$envCommonStartMenuPrograms\ Viva\Viva.lnk” -TargetPath “$PSHOME\powershell.exe” -Arguments $ShortcutArguments -IconLocation “LOCALPATH TO ICOFILE” -Description “$appName $appVersion”

Do not use the icon file from the $dirFiles dorectory, as this directory will be deleted at some point. Make sure the .ico is on a location on the local machine.

If you need double quotes, escape them so they are not considered as string terminators.
Use backtick ` to escape quotes or other characters. Single quotes disallow variable expansion.