Good morning Community,
I'm using a slight variation of a script found here: http://poshcode.org/889 to run SSIS packages. It's not too different, because why reinvent the wheel? Everything works great when I run the code from ISE; however, when I try to run the ps1 via a batch file or power shell command, it fails. Here is the error message below. Why is there a difference in execution and are there any thoughts on a workaround?
And just in case the image doesn't post, here's the text. It's teh same error in CMD as well as PS.
Running DtsxExec for package
Running: DtsxExec.ps1 || Path variable: C:\... || Server N
ame: ...dtsx || Configruation File: Not Supplied || Pre-Check Error Log Created: No
new-object : Exception calling ".ctor" with "0" argument(s): "Could not load
file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap, Version=9.0.242.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified."
At C:\...\DtsxExec.ps1:59 char:9
+ new-object ("Microsoft.SqlServer.Dts.Runtime.Application")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
new-object : Exception calling ".ctor" with "0" argument(s): "Could not load
file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap, Version=9.0.242.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified."
At C:\...\DtsxExec.ps1:59 char:9
+ new-object ("Microsoft.SqlServer.Dts.Runtime.Application")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\...\DtsxExec.ps1:131 char:21
+ $app.LoadFromDtsServer($path, $serverName, $null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Cannot Load Package. Verify Path:C:\... and
Server:...dtsx
At C:\...\DtsxExec.ps1:263 char:21
+ throw ($err)
+ ~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Cannot Load Pac...R_UnPosted.
dtsx:String) [], RuntimeException
+ FullyQualifiedErrorId : Cannot Load Package. Verify Path:C:\...\...dtsx
ECHO is off.
Waiting for 0 seconds, press a key to continue ...
C:\Subversion\PowerShellScripts>