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: 445  
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: 445  
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: 445  
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,069  
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

Installer Unable to push installs over VPN to users working from home
by  RIC   Go to last post Go to first unread
Last post: Yesterday at 12:51:32 AM(UTC)
Installer Run a PowerShell script file in a client computer
by  RIC  
Go to last post Go to first unread
Last post: 10/21/2021 12:55:49 PM(UTC)
Installer Java Uninstall Deployment
by  looktall   Go to last post Go to first unread
Last post: 10/6/2021 8:42:03 AM(UTC)
Installer Installing Windows 10 on Win 7?
by  MCBowman   Go to last post Go to first unread
Last post: 8/11/2021 9:08:51 PM(UTC)
Installer Toast Message - Reboot Computer When Patched
by  Andy.S  
Go to last post Go to first unread
Last post: 8/11/2021 12:18:30 PM(UTC)
Installer Microsoft Teams Cache Deletion
by  baritonechimpanzee   Go to last post Go to first unread
Last post: 8/5/2021 4:35:48 AM(UTC)
Installer Install Windows Updates Powershell Script
by  Mvino  
Go to last post Go to first unread
Last post: 8/4/2021 3:58:03 PM(UTC)