Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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've got a Windows 2008 r2 server with Sql Server 2008 r2 installed. I've got a Sql Server Agent which tries to run a Powershell job, but fails :-

Executed as user: FooServer\SqlServerUser. 
A job step received an error at line 1 in a PowerShell script. 
The corresponding line is '& '\\polanski\Backups\Database\7ZipFooDatabases.ps1'' 
Correct the script and reschedule the job. The error information returned
    by PowerShell is: 'File \\polanski\Backups\Database\7ZipFooDatabases.ps1
    cannot be loaded.
The file \\polanski\Backups\Database\7ZipFooDatabases.ps1 is 
    not digitally signed.
The script will not execute on the system.

Please see "get-help about_signing" for more details..  '.
Process Exit Code -1.  
The step failed.

Ok. So i run Powershell on that server then set the execution policy to unrestricted. To check ..

PS C:\Users\theUser> Get-ExecutionPolicy
PS C:\Users\theUser>

Kewl :) but it still doesn't work :(

Ok ... what happens when i try to run the powershell from the command line....

PS C:\Users\justin.adler> . '\polanski\Backups\Database\7ZipMotorshoutDatabases.ps1'

Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful,
    this script can potentially harm your computer.
Do you want to run \\polanski\Backups\Database\7ZipFooDatabases.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): 

er..... didn't I already tell the server that ANY file can be ran?

Notice the file is located at...


So can someone make any suggestions?

share|improve this question

It looks like SQL Agent jobs running powershell run the sqlps 'SQL Server Powershell' console instead of the native powershell.exe -- is it possible that the executionpolicy is set differently in this environment?

As a best test, open SQL Management Studio and right-click on the server instance name and choose Start Powershell and then run Get-ExecutionPolicy from within the SQL Server Powershell window. I'm not very familiar with this host but it's possible that it uses a different execution policy.

Additionally, it would help troubleshooting if you are running your manual powershell tests as the same account that the SQL Agent is using (since you can have per-user executionpolicy settings with Group Policy). So either run SQLPS as 'FooServer\SqlServerUser' and test, or change the SQL Agent service to run as your user account temporarily to take different user settings out of the equation.

share|improve this answer

The security warning is not caused by the execution policy setting, but IE Enhanced Security Configuration. The UNC path to your script (\\polanski\Backups\Database\) is treated like an "Internet" location, and since the security level is by default "High" for Internet locations, a security warning is issued.

So either add polanski to the "Intranet" sites zone in IE, or disable the IE ESC security warning:

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap]
share|improve this answer


Set-ExecutionPolicy Bypass 

That should do the work

-- Bypass: Nothing is blocked and there are no warnings or prompts.


share|improve this answer

I think this happens when the script you're running has been labeled by Windows as being downloaded from the Internet. If you open the properties for the file, is there a button labeled "Unblock" in the bottom right? If so, click the button and try again.

Comment Response
I missed the fact that it was being run from a UNC path. But the Unblock option would be available regardless of where the file was located. The flag is appended to the file itself in the Alternate Data Stream feature of NTFS. Regardless, it's not there. So that's not the problem.

Might the problem be that Windows considers your share path to be in the Internet zone rather than Intranet? Does it work if you move the file locally for testing?

share|improve this answer
There is no button labeled 'Unblock'. I think that option is ONLY when the file is locally stored AND was sourced from the interwebs. – Pure.Krome Apr 28 '11 at 5:17

I was having a similar issue to this and posted over on stackoverflow.

I found that PoSH executionpolicy settings are tied to IE security permissions, and that in order to use remotesigned you have to have your remote server UNC path added as a trusted site in IE, which I had done. However, I had only done it on MY IE profile on that machine. The SQL agent runs on a network acct we created for SQL services. I had to log into the server with THAT acct, and add the UNC path to THAT IE profile.

I would check to see if this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.