Notification

Icon
Error

Problems with deploying PowerShell script

Posted: Tuesday, March 31, 2020 12:15:47 PM(UTC)
Jeffy

Jeffy

Member Original PosterPosts: 2
0
Like
This issue has been solved! Click here to view the solution
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"
William382
#1William382 Member Posts: 27  
posted: 3/31/2020 7:52:13 PM(UTC)
**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.
TheITGuy
#2TheITGuy Member Posts: 32  
posted: 3/31/2020 8:29:45 PM(UTC)
or set psremoting remotely.

cmd.exe /k {actionpath}psexec.exe \\{computer} -s Enable-PSRemoting -Force
Jeffy
#3Jeffy Member Original PosterPosts: 2  
posted: 4/3/2020 10:08:28 AM(UTC)
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)

Active Discussions

Lansweeper LSPUSH and Group Policy
by  HurricaneDave   Go to last post Go to first unread
Last post: Yesterday at 10:15:12 PM(UTC)
Lansweeper How to see additional info columns on Asset Groups
by  virtualnik8  
Go to last post Go to first unread
Last post: Yesterday at 7:40:41 PM(UTC)
Lansweeper Certificate status & end dates
by  doone128   Go to last post Go to first unread
Last post: Yesterday at 11:43:46 AM(UTC)
Lansweeper O365
by  Azkor  
Go to last post Go to first unread
Last post: 9/18/2020 10:45:23 PM(UTC)
Lansweeper 2012R2: LSAgent: Could not create SSL/TLS secure channel
by  JimL   Go to last post Go to first unread
Last post: 9/18/2020 6:35:00 AM(UTC)
Lansweeper Biometric Devices
by  FrankSc   Go to last post Go to first unread
Last post: 9/17/2020 6:56:05 PM(UTC)
Lansweeper Auto Assign Agent on First Email Response
by  Elwood472  
Go to last post Go to first unread
Last post: 9/17/2020 4:33:16 PM(UTC)