当脚本路径完全限定时,在删除服务器上执行Powershell失败
我有两台服务器在同一个域上运行Windows Server 2012 R2,\tt-sql.perf.corp和\tt-file.perf.corp。文件服务器\tt file.perf.corp\fileshare\helloworld.ps1上的共享文件夹中有一个Powershell脚本。我在sql server上有一个应用程序正在执行以下命令:当脚本路径完全限定时,在删除服务器上执行Powershell失败,powershell,windows-server-2012-r2,fully-qualified-naming,Powershell,Windows Server 2012 R2,Fully Qualified Naming,我有两台服务器在同一个域上运行Windows Server 2012 R2,\tt-sql.perf.corp和\tt-file.perf.corp。文件服务器\tt file.perf.corp\fileshare\helloworld.ps1上的共享文件夹中有一个Powershell脚本。我在sql server上有一个应用程序正在执行以下命令: powershell-NonInteractive-InputFormat None-ExecutionPolicy Bypass-Command
powershell-NonInteractive-InputFormat None-ExecutionPolicy Bypass-Command“&'\tt file.perf.corp\fileshare\helloworld.ps1'
它失败,出现以下错误:
&:AuthorizationManager检查失败。第1行字符数:3
+&'\tt file.perf.corp\fileshare\helloworld.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:SecurityError:(:)[],PSSecurityException
+FullyQualifiedErrorId:未经授权的访问
如果我更改路径以使用IP地址,它也会失败
但是,当脚本的路径未完全限定时,它会起作用:
powershell-NonInteractive-InputFormat None-ExecutionPolicy Bypass-Command“&'\tt file\fileshare\helloworld.ps1'
Windows Management Instrumentation服务正在两台服务器上运行。我也在这两台服务器上运行了Get ExecutionPolicy,并且都设置为无限制。UAC在两台服务器上都被禁用。发生了什么事?您似乎已经找到了解决方法(使用短名称而不是FQDN),因此,我将尝试回答为什么您首先会遇到这个问题 可以找到一些更大的问题;实际上,这是因为当您为服务器指定FQDN时,您运行的是与PowerShell/Windows安全功能之一相冲突的。即使您指定PowerShell应绕过正常执行策略,但从FQDN运行会使Windows相信此文件来自web,因此PowerShell希望向您显示如下警告:
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
\\tt-file.perf.corp\fileshare\helloworld.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"):
但它不能,因为您正在非交互模式下运行shell
所以你有两个选择来解决这个问题,真的:
我希望这有帮助!不幸的是,我想不出一个好的PowerShell方法来解决这个问题:) 谢谢你提供的信息,这就解释了。你知道为什么我不会在另一个内部域上看到这个问题吗?据我所知,没有将域添加到本地intranet的组策略,并且没有在IE中进行设置。我不确定在其他地方可以找到允许它工作的内容。Internet Explorer中也有一个设置,与我之前提到的受信任站点相同,无论如何,您可以单击一个复选框,它将自动确定intranet站点并绕过安全性。也许那个框被选中了?