我有以下PowerShell脚本连接到远程Sql Server集成服务:
param (
[string]$Server = "GFDBS0002",
[string]$Instance = "DEFAULT",
[string]$Folder = "<SSIS folder>",
[string]$Project
)
Import-Module sqlps -DisableNameChecking
$p = Get-Item SQLSERVER:\SSIS\$Server\$Instance\Catalogs\SSISDB\Folders\$Folder\Projects\$Project
执行脚本失败:
“警告:无法获取SQL Server服务信息。尝试 连接到'GFDBS0002'上的WMI失败,出现以下错误: 拒绝访问。 (Undtagelse fra HRESULT:0x80070005(E_ACCESSDENIED))“
关于我可以做什么来连接的任何建议?
根据@ArcSet的回答,以下解决方案有效:
$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
$p = Get-Item SQLSERVER:\SSIS\$Server\$Instance\Catalogs\SSISDB\Folders\$Folder\Projects\$Project -Credential $mycreds
答案 0 :(得分:1)
WMI连接未通过您的身份,需要您使用您的凭据登录。
var s = "00001111";
var n = 0d;
for(var i = 0; i < s.Length; i++)
{
var d = s[s.Length - 1 - i] == '0' ? 0 : 1;
n += (d * Math.Pow(2, i));
}
var b = (byte)(((int)n) & 0xFF);