Hello,
Im trying to run a action script task that runs a powershell script to connect a printer to an end device.
Here is my script
if { not exists folder “C:\software\Scripts” }
waithidden cmd.exe /C mkdir "C:\software\Scripts"
endif
parameter “baseFolder” = “C:\software\Scripts”
waithidden C:\Windows\System32\icacls.exe {parameter “baseFolder”} /grant “Everyone:(OI)(CI)F”
delete __createfile
createfile until end
Add-Printer -ConnectionName \sup-ap-pwvprint\acct1
start-sleep -seconds 15
end
copy __createfile {parameter “baseFolder”}\corpprints.ps1
waithidden { pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy RemoteSigned -File C:\Software\Scripts\corpprints.ps1
pause while {exists running application “powershell.exe”}
waithidden powershell remove-item -Path C:\Software\Scripts -Recurse -Force
When I try to deploy it as a task this happens.

I have tried every way under the sun to set this to ByPass the Execution Policy but nothing is working.
I have tried running this as a PowerShell script, action script. Tried changing the script around 10 different ways, making variables to hold the information to running the script as you would normally. I can run this script No issue from the desktop. It works just fine no issue from PowerShell. Only when i run it as a task does it fail like this.
The user running the task is a DomainAdamin as well. Not sure why its happening.
Does anyone have any ideas or tips to try? This would save me a lot of manual time if I could just add printers from the server through a task.