powershell - SSIS 包中的 Powershell RunAs 管理员
问题描述
我正在尝试远程连接到服务器并运行 powershell 脚本以在 SSIS 执行进程任务中打开 Windows 防火墙中的端口
这是 Powershell 代码:
$computername = hostname
$script = {
$FireWallRule_1 = Get-NetFirewallRule
$par1 = @{
DisplayName = "DAC"
LocalPort = 1434
Direction="Inbound"
Protocol ="TCP"
Action = "Allow"
}
$FireWallRule_2 = Get-NetFirewallRule
$par2 = @{
DisplayName = "MSSQLSERVER"
LocalPort = 1433
Direction="Inbound"
Protocol ="TCP"
Action = "Allow"
}
$par1.Localport = 1434
$par1.DisplayName = "DAC"
if (-not $FireWallRule_1.DisplayName.Contains($par1.DisplayName)) {New-NetFirewallRule @par1}
$par2.LocalPort = 1433
$par2.DisplayName = "MSSQLSERVER"
if (-not $FireWallRule_2.DisplayName.Contains($par2.DisplayName)) {New-NetFirewallRule @par2}
}
Invoke-Command -ScriptBlock $script -ComputerName $computername
这是我得到的错误:
连接到远程服务器 [SERVERNAME] 失败并显示以下错误消息:访问被拒绝。有关详细信息,请参阅 aboute_Remote_Troubleshooting 帮助主题。+ CategoryInfo : OpenError: (SERVERNAME:String) [], PSRemotingTransportException + FullyQualifiederrorId : AccessDenied, PSSessionStateBroken
我试图在本地运行 PS 脚本及其工作,运行 ssis 的帐户是目标服务器上的本地管理员。是否可以在 SSIS 包中以管理员身份运行?
谢谢哈坎
解决方案
推荐阅读
- jquery - 使用 .closest 在 div 中获取具有值的输入字段
- aem - AEM:如何使用资源类型获取已注册的吊索模型列表
- macos - Safari 12 中不受支持的 Safari 扩展的修复/解决方法?
- angular - Cross-Origin Request Blocked Angular 4,POST Request
- java - Generate array with random numbers
- ruby - 我可以选择关闭公用文件夹下的默认页面吗?
- r - Running raster::stackApply() function in parallel
- go - 只读来自 HTTP 处理程序的共享结构时如何防止竞争条件
- swagger - Swagger - 逗号分隔的参数列表
- javascript - 如何将 Github 所见即所得编辑器导入 HTML?