/build/static/layout/Breadcrumb_cap_w.png

Kace - Running PowerShell Script from UNC Path

Kace - Running PowerShell Script from UNC Path

I'm just learning, hoping someone has some insight...

If I run a .ps1 scrip from a UNC path: c:\<path>\powershell.exe -ep bypass -file "\\server\share\<path>\script.ps1"

As the local system, the agent does not appear to have access (permission) to the UNC path. However, If I run it as an account that is an admin on the local machine and has permissions to the UNC path, the script runs, but I get a UAC prompt when that script launches the installer that it's supposed to...

Any Ideas, work-arounds?

Thank you,

Adam

0 Comments   [ + ] Show comments

Answers (2)

Posted by: SMal.tmcc 9 years ago
Red Belt
1
the agent is running as system so it cannot login. 

Solution 1 create a readonly share that everyone has rights to, even non-domain users
Solution 2 add a net use command to map a drive letter in your script with credentails to access the schare and run from the drive and then net use /delete when done

net use k: \\server\share\<path> /user:someuser somepassword
on success
c:\<path>\powershell.exe -ep bypass -file "k:\script.ps1"
net use k: /delete

Posted by: EdT 9 years ago
Red Belt
0
I would definitely suggest that solution 2 is the more secure option of the two, as solution 1, basically a null session share, leaves the share wide open to absolutely anyone.  What you may wish to consider is programming an EXE that you can call from your script which makes the connection to the share, so that the connection credentials are hidden.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ