简体   繁体   English

远程Powershell访问被拒绝

[英]Remote Powershell Access Denied

I have a SQL Server database with some tables and a trigger, the trigger would create either FolderA on ServerA or FolderB on ServerB, this is the command I pass in the trigger for ServerA: 我有一个带有一些表和触发器的SQL Server数据库,该触发器将在ServerA上创建FolderA或在ServerB上创建FolderB,这是我在ServerA的触发器中传递的命令:

SET @folder = 'powershell.exe  invoke-command -computername ServerA { powershell.exe  -NoProfile -ExecutionPolicy Bypass  -File C:\FolderScript\FolderA.ps1 "' +@folderName+'" }'

EXEC master.dbo.xp_cmdshell @folder

I have an intermittent issues with it, it will work just fine for couple of days before it stops then I would have to run it manually from PS on ServerA. 我有一个间歇性的问题,它会在停止前几天正常工作,然后我必须从ServerA上的PS手动运行它。

Because it's intermittent, then we can rule out firewall, permissions, PowerShell enable remote. 因为它是间歇性的,所以我们可以排除防火墙,权限,PowerShell启用远程。 I have a web based application (asp.net) that users run from their machines and it connect to the SQL Server database where the trigger is located. 我有一个基于Web的应用程序(asp.net),用户可以在自己的计算机上运行该应用程序,并将其连接到触发器所在的SQL Server数据库。

Is there some sort of sessions that needs to stay open to prevent access denied error? 是否有某种会话需要保持打开状态以防止访问被拒绝错误? I can't think of anything else that might cause this issue? 我想不出其他任何可能导致此问题的原因?

I suspect the issue is with your quoting happening in the command: 我怀疑问题出在您的命令中:

SET @folder = 'powershell.exe -Command "Invoke-Command -ComputerName ServerA { & ''C:\FolderScript\FolderA.ps1'' ' + @folderName + ' }"'

This should be sufficient to resolve your issue. 这应该足以解决您的问题。 You do not need to repeatedly call powershell.exe as you can natively call scripts with the call operator ( & ). 您无需重复调用powershell.exe因为您可以使用调用运算符( & )本地调用脚本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 链接服务器-拒绝访问远程服务器 - Linked Server - Access to the remote server is denied 使用PowerShell远程连接到SQL Integration Services时访问被拒绝 - Access Denied when connecting remotely to SQL Integration Services using PowerShell azure webjob连接到远程mssql实例。 拒绝访问 - azure webjob connect to remote mssql instance. Access Denied 拒绝访问远程服务器,因为SQL Server代理作业中不信任当前安全上下文 - Access to the remote server is denied because the current security context is not trusted in SQL Server agent job 来自数据库执行的错误消息:因为不存在登录映射,所以拒绝访问远程服务器 - Error message from database execution: Access to the remote server is denied because no login-mapping exists 拒绝访问远程服务器,因为当前的安全上下文不受信任,SQL Server代理 - Access to the remote server is denied because the current security context is not trusted, SQL server agent “ASP.NET”错误:拒绝访问远程服务器,因为不存在登录映射 - “ASP.NET” error: Access to the remote server is denied because no login-mapping exists 由于双跳故障,委派受约束,远程Powershell请求中的SSPI SQL访问失败 - SSPI sql access fails in remote powershell request due to double-hop failure, constrained delegation 还原备份访问被拒绝 - Restore Backup Access Denied Powershell 远程服务器上的脚本失败 - Powershell Script failure on Remote Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM