Hi,
I have a PowerShell script that (among other things) establishes a connection to the SSISDB catalog. In my environment, the connection is made successfully. The same script fails in a different environment. I suspect environmental conditions, but I'm not sure how to track this down.
The relevant script snippet is:
$global:cat = 0
$global:ISNamespace = ''
$global:ssis = 0
$global:con = ''
#--------------------------------------------
#set-psdebug -trace 2
# Load the IntegrationServices Assembly
$loadStatus = [Reflection.Assembly]::Load("Microsoft"+
".SqlServer.Management.IntegrationServices" +
", Version=11.0.0.0, Culture=neutral" +
", PublicKeyToken=89845dcd8080cc91")
# Store the IntegrationServices Assembly namespace to avoid typing it every time
$global:ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
Write-Host "Connecting to server ..." -f cyan
# Create a connection to the server
$global:constr = "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;"
$global:con = New-Object System.Data.SqlClient.SqlConnection $constr
# Create the Integration Services object
$global:ssis = New-Object $ISNamespace".IntegrationServices" $con
The last line fails on the target host (script is run local in both cases):
New-Object : Exception calling ".ctor" with "1" argument(s): "Failed to connect to server ."
At C:\Users\jpage\documents\scripts\check1.ps1:24 char:27
+ $global:ssis = New-Object <<<< $ISNamespace".IntegrationServices" $con
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Any help would be appreciated.
Thanks