cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Lewis_Spokane
Engaged Sweeper III

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?

1 ACCEPTED SOLUTION
CyberCitizen
Honored Sweeper
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.

View solution in original post

6 REPLIES 6
FreddieIT
Engaged Sweeper
You could try this;

powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file C:\Temp\powershellscript.ps1' -verb RunAs}"
Esben_D
Lansweeper Employee
Lansweeper Employee
Every time I've done it I've always used what Cyber mentioned. It is also mentioned in this old thread: https://www.lansweeper.com/forum/yaf_postst10730_PowerShell-from-Deployment-Package.aspx
CyberCitizen
Honored Sweeper
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"
CyberCitizen
Honored Sweeper
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.
Lewis_Spokane
Engaged Sweeper III
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
Honored Sweeper
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.