Running script on UNC as another user

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
ShawnSifford
Posts: 5
Last visit: Wed Mar 06, 2024 6:37 am

Running script on UNC as another user

Post by ShawnSifford »

If I launch Powershell Studio 2015 as myself and load a script that is stored in a UNC path I can get it to run. If I launch Powershell Studio 2015 as a different user and load a script that is stored in a UNC path I cannot get it to run even though the settings between the two users are the same. I get "File \\server.domain\scriptname.ps1 cannot be loaded. The file \\server.domain\scriptname.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details". I have tried unrestricted and bypass for the shell execution policy. If I run the script using Run in Console it does run. Ideas?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Running script on UNC as another user

Post by davidc »

Can you edit and save the file using the alternate user?

Note: You might have to set the executable policy for both x86 and x64 versions of PowerShell. Go to Options->PowerShell->Change Execution Policy. A window will pop up that will allow you to set the policy for both versions of PowerShell.

David
David
SAPIEN Technologies, Inc.
User avatar
ShawnSifford
Posts: 5
Last visit: Wed Mar 06, 2024 6:37 am

Re: Running script on UNC as another user

Post by ShawnSifford »

Yes, I can edit and save the script as the other user.

I have changed the execution policy for both 32 and 64 bit. I have tried unrestricted as well as bypass.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Running script on UNC as another user

Post by davidc »

I have a few more questions for you:

1. What OS are you running?
2. What version of PowerShell do you have installed? If you have V3 or greater installed, verify that you are not running the script in V2 mode.
3. Can you run the script if you copy it locally? Make sure the script location is accessible to the alternative user.

Note: Sometimes Group Policies can impose restrictions on particular users.

David
David
SAPIEN Technologies, Inc.
User avatar
ShawnSifford
Posts: 5
Last visit: Wed Mar 06, 2024 6:37 am

Re: Running script on UNC as another user

Post by ShawnSifford »

Windows 7
Powershell V2
I can run it locally. The script on the UNC path is available to the alternate user. I can run it from there with Powershell and PowerGUI.

The error I am getting is about it not being signed.

File \\server.domain\path\script.ps1 cannot be loaded. The file \\server.domain\path\script.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details

If I run a local script with just the cmdlet Get-ExecutionPolicy as the contents it returns RemoteSigned if I just run it (F5) but returns Unrestricted if I run it in the console (Ctrl+Shift=F5).
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Running script on UNC as another user

Post by davidc »

Run PowerShell Studio as the alternate user then press the following icon on the quick access bar:
Execution Policy.png
Execution Policy.png (15.84 KiB) Viewed 17096 times
If the button is not present, go to Options->PowerShell->Change Execution Policy.
Option Change Execution Policy.png
Option Change Execution Policy.png (25.62 KiB) Viewed 17096 times
Let us know what the Execution Policy Manager displays:
PowerShellPolicyManager.png
PowerShellPolicyManager.png (20.21 KiB) Viewed 17096 times
David
David
SAPIEN Technologies, Inc.
User avatar
ShawnSifford
Posts: 5
Last visit: Wed Mar 06, 2024 6:37 am

Re: Running script on UNC as another user

Post by ShawnSifford »

Interesting. Setting it by the red button at the top now works as long as it is set to Unrestricted. However Bypass gets the same error as before.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Running script on UNC as another user

Post by davidc »

You can get this error if your script was downloaded from the internet or if ran from a UNC path (even if it was not downloaded from the internet). This Scripting Guy article tells you how to get around this issue:

http://blogs.technet.com/b/heyscripting ... ctory.aspx


David
David
SAPIEN Technologies, Inc.
User avatar
ShawnSifford
Posts: 5
Last visit: Wed Mar 06, 2024 6:37 am

Re: Running script on UNC as another user

Post by ShawnSifford »

I already have the UNCAsIntranet setting set. Thus the reason I don't have any issues running scripts from UNC paths in either Powershell or PowerGUI as stated before. The only problem I am having now is running one from a UNC in Powershell Studio as another user. It is now running in Unrestricted but when set to Bypass it still won't run. In Unrestricted it prompts with the security warning asking if I want to run the file which is more than a little annoying when developing. In my environment my main user account has no rights/privileges. I have a secondary account for administration. All scripts have to be developed and run under that second script. Also our virtual desktops have little to no free space so I must keep all of my data on network drives. So I must develop scripts on UNC paths while running under alternate credentials. I am really liking this software but this will be a deal breaker for us here.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Running script on UNC as another user

Post by davidc »

We have been trying to reproduce this on our end but have been unable to. Unfortunately we do not know what group policies or local settings you may have that affect this and don't have access your system to determine the cause for Windows and/or PowerShell restricting your access.

If you haven't already, you might want to try running the scripts using elevation and see if that makes a difference.
Elevation Setting.png
Elevation Setting.png (7.97 KiB) Viewed 17039 times
Note: PowerShell Studio runs the scripts out of process, so if you have any policies that require permissions, then these external processes will need to be included as exceptions:

C:\Program Files (x86)\Common Files\SAPIEN Debugger 2015

Since the PowerShell engine is restricting access, I would highly recommend contacting the Microsoft PowerShell team. They can provide insight to the inner workings of the PowerShell engine.

David
David
SAPIEN Technologies, Inc.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.