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

Action Setting Computer AD Description Attribute
by  DJSMC   Go to last post Go to first unread
Last post: 10/4/2020 4:46:17 PM(UTC)
Action Open Teams/SfB Chat with user
by  marceman  
Go to last post Go to first unread
Last post: 9/10/2020 4:10:18 PM(UTC)
Lansweeper Report showing app even after it has gone
by  TimHolmes1973   Go to last post Go to first unread
Last post: 9/9/2020 11:50:17 PM(UTC)
Action Remote Device Manager
by  steveb  
Go to last post Go to first unread
Last post: 9/4/2020 9:52:01 PM(UTC)
Action View Windows Defender detections remotely
by  steveb   Go to last post Go to first unread
Last post: 9/4/2020 9:37:48 PM(UTC)
Action Remote Uninstaller
by  steveb  
Go to last post Go to first unread
Last post: 9/4/2020 9:27:17 PM(UTC)
Lansweeper Filter Assets' groups by WinSystemLocale
by  Alex Beaumier   Go to last post Go to first unread
Last post: 8/20/2020 4:17:17 PM(UTC)
Action Chrome History
by  csys  
Go to last post Go to first unread
Last post: 8/14/2020 2:14:21 PM(UTC)