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: 25  
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 Lost Configuration tab (Admin rights)
by  kspap   Go to last post Go to first unread
Last post: Today at 10:30:12 AM(UTC)
Lansweeper Deployment with different user rights
by  Jupiter_IT  
Go to last post Go to first unread
Last post: Today at 9:39:20 AM(UTC)
Lansweeper cisco fuji device not linking with connected devices
by  char   Go to last post Go to first unread
Last post: Yesterday at 9:12:07 AM(UTC)
Lansweeper Microsoft CVE-2020-1425
by  Richard_B  
Go to last post Go to first unread
Last post: 7/3/2020 4:29:41 PM(UTC)
Lansweeper Wake on Lan in VLANs
by  FrankSc   Go to last post Go to first unread
Last post: 7/3/2020 1:56:46 PM(UTC)
Lansweeper Ticket Closed = email to all helpdesk desk agents
by  Laurent Maene  
Go to last post Go to first unread
Last post: 7/3/2020 1:23:49 PM(UTC)
Lansweeper Helpdek Call Re-Opened
by  pryan67   Go to last post Go to first unread
Last post: 7/3/2020 1:12:17 PM(UTC)
Lansweeper Office 365 32bit vs 64bit?
by  brodiemac-too  
Go to last post Go to first unread
Last post: 7/2/2020 10:35:19 PM(UTC)