Notification

Icon
Error

Deploying PowerShell script

Posted: Thursday, October 31, 2019 11:56:08 PM(UTC)
Lewis_Spokane

Lewis_Spokane

Member Original PosterPosts: 14
0
Like
This issue has been solved! Click here to view the solution
I have a PowerShell script to install a piece of software. If put the .ps1 file in the scripts folder of the {PackageShare} what do i do with all the files that script is going to call on?

Do I put the entire package in the scripts folder?
CyberCitizen
#1CyberCitizen Member Posts: 440  
posted: 11/1/2019 2:20:12 AM(UTC)
It depends, but the script needs to know where to get those files from so if the script is hardcoded to a UNC path (file share) then it needs to stay in that location, however the users need access.

If it looks to the directy the script is running from then it needs to be in the same directory.
Lewis_Spokane
#2Lewis_Spokane Member Original PosterPosts: 14  
posted: 11/1/2019 6:41:25 PM(UTC)
Thank you, that is helpful.

What I have only seems to work when I run it from Administrative prompt (cmd or powershell), how do I indicate to the deployment package that it should open an elevated session?
CyberCitizen
#3CyberCitizen Member Posts: 440  
posted: 11/3/2019 11:54:40 PM(UTC)
Use the scanning credentials for elevated prompt.

System can work, however my previous experience with SYSTEM is that it can't connect to network paths / shares.
CyberCitizen
#4CyberCitizen Member Posts: 440  
posted: 11/3/2019 11:55:45 PM(UTC)
Note you might also need to do something like this (executionpolicy bypass) to allow the script to actually run.

powershell.exe -executionpolicy bypass -file "{PackageShare}\CleanUpMGRScript.ps1"
Esben.D
#5Esben.D Member Administration Posts: 2,055  
posted: 11/4/2019 4:15:20 PM(UTC)
Every time I've done it I've always used what Cyber mentioned. It is also mentioned in this old thread: https://www.lansweeper.c...-Deployment-Package.aspx
FreddieIT
#6FreddieIT Member Posts: 1  
posted: 8/3/2021 10:57:34 AM(UTC)
You could try this;

powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file C:\Temp\powershellscript.ps1' -verb RunAs}"

Active Discussions

Lansweeper History of relationship between pc and monitor
by  hfaddy  
Go to last post Go to first unread
Last post: Yesterday at 1:44:38 PM(UTC)
Lansweeper New Hire Login Request Report
by  Scott Davis   Go to last post Go to first unread
Last post: 9/16/2021 7:16:46 PM(UTC)
Lansweeper SCCM end of life
by  Esben.D  
Go to last post Go to first unread
Last post: 9/16/2021 2:56:23 PM(UTC)
Lansweeper Microsoft Patch Tuesday – September 2021
by  Esben.D  
Go to last post Go to first unread
Last post: 9/14/2021 8:27:06 PM(UTC)
Lansweeper Apple “FORCEDENTRY” Zero-Day Vulnerability
by  Esben.D   Go to last post Go to first unread
Last post: 9/14/2021 12:07:54 PM(UTC)
Lansweeper ALL laptops HP 340S G7 Notebook PC and Bios version
by  Carlos Montes  
Go to last post Go to first unread
Last post: 9/13/2021 3:17:19 PM(UTC)