cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jeffy
Engaged Sweeper
Hello guys, i have a problem because I can't deploy new package with PS script. I'm using:

powershell.exe -executionpolicy bypass -command {"commands go here"} (Setting action command)

or

powershell.exe -executionpolicy bypass -file "{PackageShare}\Scripts\script.ps1" (Setting action script)

and I'm getting result:

Deployment ended: Incorrect function. Stop(Failure).

and

Result: Deployment ended: Incorrect function. Stop(Failure). Credential: (******). ShareCredential: (******). Command: "PowerShell.exe -ExecutionPolicy Bypass \\******\PackageShare$\Installers\Scripts\Script.ps1"
1 ACCEPTED SOLUTION
Jeffy
Engaged Sweeper
The problem wasn't bad command or unsupported environment, but the problem was with the numbers of remote connections. Powershell only allows one and that's already taken up by lansweeper. So the solution is:

powershell.exe -executionpolicy bypass -file \\computer\PackageShare$\Installers\Scripts\Script.ps1 (Setting action command)

View solution in original post

4 REPLIES 4
Jeffy
Engaged Sweeper
The problem wasn't bad command or unsupported environment, but the problem was with the numbers of remote connections. Powershell only allows one and that's already taken up by lansweeper. So the solution is:

powershell.exe -executionpolicy bypass -file \\computer\PackageShare$\Installers\Scripts\Script.ps1 (Setting action command)
Ruben1
Engaged Sweeper III
Jeffy wrote:
The problem wasn't bad command or unsupported environment, but the problem was with the numbers of remote connections. Powershell only allows one and that's already taken up by lansweeper. So the solution is:

powershell.exe -executionpolicy bypass -file \\computer\PackageShare$\Installers\Scripts\Script.ps1 (Setting action command)


What do you mean with your solution? Am I missing something? You have typed the same command as in your question and didn't provide a solution for the number of remote connections.
TheITGuy
Engaged Sweeper III
or set psremoting remotely.

cmd.exe /k {actionpath}psexec.exe \\{computer} -s Enable-PSRemoting -Force
William382
Engaged Sweeper III
**Disclaimer, this works for me, but may not be the safest best. Please let me know if I can get this any better.



That syntax looks correct. My working PS script:

"powershell.exe -executionpolicy bypass -file "{PackageShare}\Scripts\Printers.PS1""

So you need to ensure your environment supports PS remote scripts and you have permission on the PC AND WinRm is configured. This is best done through group policy or you need to PSExec into each PC to perform.

GPO
Comp -> Policies -> Admin temp -> Windows comp -> W. powershell ->
Turn on powershell transcription - enabled set location

Comp -> Policies -> Admin temp -> Windows comp -> Win remote mgmt -> WinRM/WinRM Client
Allow Basic authentication - Disabled
Trusted Hosts - enabled. Set IPs for my LS server

Comp -> Policies -> Admin temp -> Windows comp -> Win remote mgmt -> WinRM/WinRM Server
Allow remote server magmt through WinRM - Set to all "*"

Set the WINRM service to start through GPO services.


Hope this helps.