Kenci
Kenci

Reputation: 4882

Access Denied when connecting remotely to SQL Integration Services using PowerShell

I have the following PowerShell script to connect to a remote Sql Server Integration Service:

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

Executing the script fails with:

"WARNING: Could not obtain SQL Server Service information. An attempt to connect to WMI on 'GFDBS0002' failed with the following error: Access Denied. (Undtagelse fra HRESULT: 0x80070005 (E_ACCESSDENIED))"

I can successfully connect to the server with Windows Management Instrumentation Tester with my AD-user:

enter image description here

Any suggestions on what I could do to connect ?

Solution

Based on the answer by @ArcSet, the following solution worked:

$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

Upvotes: 0

Views: 700

Answers (1)

ArcSet
ArcSet

Reputation: 6860

The WMI connection doesn't pass your identity and will need you to sign in with your credentials.

Get-Item -Credential (Get-Credential)

Upvotes: 1

Related Questions