我有安装了Sql Server 2008 R2的Windows 2008 R2服务器。 我有一个Sql Server代理尝试运行PowerShell作业,但失败: –
Message 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.
好。 所以我在该服务器上运行Powershell,然后将执行策略设置为不受限制。 去检查 ..
PS C:\Users\theUser> Get-ExecutionPolicy Unrestricted PS C:\Users\theUser>
Kewl :)但它仍然无法工作:(
好的…当我尝试从命令行运行powershell时会发生什么情况….
PS C:\ Users \ justin.adler>。 '\波兰斯基\备份\数据库\ 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"):
呃…..没有我已经告诉服务器,任何文件可以运行?
注意该文件位于…
\\polanski\Backups\Database\
那么有人可以提出任何build议吗?
它看起来像运行PowerShell的SQL代理作业运行SQLPS的“SQL Server Powershell”控制台,而不是本机powershell.exe是否有可能执行策略在此环境中设置不同?
作为最佳testing,打开SQL Management Studio并右键单击服务器实例名称,然后select启动PowerShell,然后在SQL Server PowerShell窗口中运行Get-ExecutionPolicy。 我对这个主机不是很熟悉,但它可能会使用不同的执行策略。
此外,如果您将手动PowerShelltesting作为SQL Agent使用的相同帐户运行(因为您可以通过组策略设置每个用户的执行策略设置),它将有助于排除故障。 因此,将SQLPS作为“FooServer \ SqlServerUser”运行并testing,或者将SQL代理服务暂时作为用户帐户运行,以将不同的用户设置从等式中排除。
安全警告不是由执行策略设置引起的,而是由IE增强安全configuration引起的 。 脚本( \\polanski\Backups\Database\ )的UNCpath被视为“Internet”位置,由于Internet位置的安全级别默认为“高”,因此会发出安全警告。
因此,要么将polanski添加到IE中的“Intranet”站点区域,要么禁用IE ESC安全警告:
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap] "UNCAsIntranet"=dword:00000000
尝试
Set-ExecutionPolicy Bypass
这应该做的工作
– 绕道:没有任何东西被阻塞,没有警告或提示。
资源
我认为这发生在您运行的脚本被Windows标记为从Internet下载时发生。 如果您打开文件的属性,右下angular是否有一个标有“解除阻止”的button? 如果是这样,请点击button,然后重试。
评论回应
我错过了从UNCpath运行的事实。 但是,无论文件位于何处,“解除阻止”选项都可用。 在NTFS的备用数据streamfunction中,该标志附加到文件本身。 无论如何,它不在那里。 所以这不是问题。
可能问题是Windows认为你的共享path是在Internet区域而不是Intranet? 如果您在本地移动文件进行testing,它是否工作?
我有一个类似的问题,并张贴在stackoverflow上。
我发现PoSH executionpolicy设置绑定到IE安全权限,并且为了使用remotesigned,你必须把你的远程服务器UNCpath添加为IE中的可信站点,这一点我已经完成了。 但是,我只在该机器的IE浏览器configuration文件上完成了这项工作。 SQL代理在我们为SQL服务创build的networkingacct上运行。 我必须用THATACClogin到服务器,并将UNCpath添加到该IEconfiguration文件。
我会检查,看看这是否有帮助。