Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using VirtualBox with a shared folder mapped to drive E:. I want to run a PowerShell script from drive E:. I set:

Set-ExecutionPolicy Remotesigned

I added file://vboxserver using the advanced dialog to the local intranet.

When I load "E:\System_Data_SQLClient_test.ps1" into PowerShell ISE I get:

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

At line:0 char:0

When I use the UNC path to the shared folder it works:

\\VBOXSVR\WSV-BK-7en64-C\System_Data_SQLClient_test.ps1

What is missing here to be able to access the script via drive letter?

share|improve this question
    
How do you execute the command using the unc path? I'm trying to do the same things with a simple string output script but it trows me the same error as if try to execute it with the drive letter. When i first read you problem I though it refers to te situation described here blogs.technet.com/b/heyscriptingguy/archive/2011/01/04/… but after check the file properties of any file in the share i see that they don't have the zone identifier so the problem is other thing. Maybe is the file type of the share, a weird VBoxSharedFolderFS – mjsr Oct 4 '11 at 11:17
    
I'm always using ISE. I load either the script from a local disk, via unc from the shared folder or via drive letter from the latter shared folder. – bernd_k Oct 4 '11 at 11:21
    
I change the execution-policy to "unrestricted" and perhaps that it trows me a security warning message, in that message i have to select "run once" and the script run. But is weird, it recognized that is a external location even if the files don't have the Zone.Identifier. I think that definetilly has something to do with the way that VirtualBox create that share. – mjsr Oct 4 '11 at 11:37
up vote 3 down vote accepted

bernd_k i found a nice solution to execute all the script that you have in the shared folder, create a directory symlink to the share, that is all!!

Suppose the actual location is c:\users\x. Run this in cmd as admin:

 mklink /d NameforMyScriptFolder \\vboxsvr\share\RealScriptFolder

then go to that folder, in powershell as normal user and run whatever you want:

  cd c:\users\x\NameforMy*
  executewhateverscript.ps1 #:D

pd: change the name of the question because it doesn't reflect what you really ask.

share|improve this answer
    
Please improve your answer by adding that you have to add 'file://vboxsvr' to Local Intranet Sites. – bernd_k Oct 9 '11 at 10:53
    
Hi bernd_k I don't know what you mean with "add to Local Intranet Sites", could you tell me more about it?...and in my configuration the only thing that i need was to set the execution policy as remotesigned and create the symlink – mjsr Oct 10 '11 at 0:24
    
You seem to have reduced some security defaults. To give you a hint cf. stackoverflow.com/questions/1559969/… and stackoverflow.com/questions/972345/…. Usually I do it with the GUI, sorry I find no link with pictures. You have to start IE| Tools| Internet options | security | local intranet | sites | Advanced. There you can add file://vboxsvr. – bernd_k Oct 10 '11 at 5:27
    
mmm I think that is completely unnecesary and unrelated to powershell script execution, remove it from the trusted list and try to run the scripts – mjsr Oct 10 '11 at 9:13
    
For me it is definite necessary, when the script is not on a local drive. I rechecked it 2 times. – bernd_k Oct 10 '11 at 10:18

I finally found the working solution

Add file://vboxsvr to Local Intranet Sites

Set-ExecutionPolicy RemoteSigned

mklink /d hostfiles \\VBOXSVR\WSV-BK-7en64-C

Thanks to voodoomsr for giving this alternative way avoiding drive letters.

The main problem is to remember the correct syntax when adding the share to local Intranet.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .