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: 24  
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 Automated warranty check not working for HP
by  Erik.T   Go to last post Go to first unread
Last post: Today at 5:40:25 PM(UTC)
Lansweeper Guide: Get Every Asset MAC Addresses From Every Subnet
by  Erik.T  
Go to last post Go to first unread
Last post: Today at 5:38:15 PM(UTC)
Lansweeper Vcenter Scanning Credential
by  Erik.T   Go to last post Go to first unread
Last post: Today at 5:33:58 PM(UTC)
Lansweeper SCCM Integration
by  Erik.T  
Go to last post Go to first unread
Last post: Today at 5:29:26 PM(UTC)
Lansweeper SATA MODE REPORT
by  Erik.T   Go to last post Go to first unread
Last post: Today at 5:20:37 PM(UTC)
Lansweeper Scanning - computer manufacturer shows as VPN though
by  Erik.T  
Go to last post Go to first unread
Last post: Today at 5:14:34 PM(UTC)
Lansweeper Lastlogon / lastlogondate
by  Erik.T   Go to last post Go to first unread
Last post: Today at 5:13:16 PM(UTC)
Lansweeper SNMP and not in English
by  Erik.T  
Go to last post Go to first unread
Last post: Today at 5:01:56 PM(UTC)