Leo Torres
asked on
Import SSIS packages with Powershell
I need to Import a directory of files and folder into a SQL
The folder contains sub-folders that live in SSIS but if there not there it should create them..
The folder contains sub-folders that live in SSIS but if there not there it should create them..
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
OK not Connecting
Here is the error
Exception calling "CreateFolderOnDtsServer" with "3" argument(s): "Connecting to the Integration Services service on the computer "-08" failed with t
he following error: "The RPC server is unavailable.
".
This error occurs when the computer host name does not exist, or cannot be reached.
"
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:571 char:35
+ Â Â { $app.CreateFolderOnDtsServ er <<<<Â ($path, $value, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Code below
Here is the error
Exception calling "CreateFolderOnDtsServer" with "3" argument(s): "Connecting to the Integration Services service on the computer "-08" failed with t
he following error: "The RPC server is unavailable.
".
This error occurs when the computer host name does not exist, or cannot be reached.
"
At \\pcna-02\mydocs\ltorres\M
+ Â Â { $app.CreateFolderOnDtsServ
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Code below
import-module SSIS
new-isitem 'msdb' 'Test' $env:PCSQ-08
ASKER
I know I can connect I just did with SSMS..
Any idea?
Any idea?
ASKER
Do I have to run this command locally?
Seems like it is that what the $env:computername does
I did it from another machine..will that not work?
Seems like it is that what the $env:computername does
I did it from another machine..will that not work?
try this:
new-isitem '\msdb' 'Test' 'PCSQ-08'
new-isitem '\msdb' 'Test' 'PCSQ-08'
ASKER
error..
Path \msdb\Test already exists!
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:573 char:12
+ Â Â { throw <<<<Â "Path $testPath already exists!" }
  + CategoryInfo      : OperationStopped: (Path \msdb\Test already exists!:String) [], RuntimeException
  + FullyQualifiedErrorId : Path \msdb\Test already exists!
Path \msdb\Test already exists!
At \\pcna-02\mydocs\ltorres\M
+ Â Â { throw <<<<Â "Path $testPath already exists!" }
  + CategoryInfo      : OperationStopped: (Path \msdb\Test already exists!:String) [], RuntimeException
  + FullyQualifiedErrorId : Path \msdb\Test already exists!
ASKER
Not sure I follow here  sorry..
The packages I want to import are sitting here
\\pcna-02\mydocs\ltorres\M y Documents\SSIS_Packages\PC SQ-02
Where so I specify this
The packages I want to import are sitting here
\\pcna-02\mydocs\ltorres\M
Where so I specify this
try:
copy-isitemfiletosql -path "\\pcna-02\mydocs\ltorres\My Documents\SSIS_Packages\PCSQ-02\*" -destination '\msdb\Test' -destinationServer 'PCSQ-08'
ASKER
Yes, I tried
got this error
copy-isitemfiletosql -path "\\pcna-02\mydocs\ltorres\ My Documents\SSIS_Packages\PC SQ-02_test \*" -destination "msdb\Test" -destinationServer 'PCSQ-08' -connectionInfo @{SSISCONFIG=".\SQLEXPRESS "}
The term 'copy-isitemfiletosql' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a p
ath was included, verify that the path is correct and try again.
At line:3 char:21
+ copy-isitemfiletosql <<<<Â -path "\\pcna-02\mydocs\ltorres\ My Documents\SSIS_Packages\PC SQ-02_test \*" -destination "msdb\Test" -destinationServer 'PCSQ-08' -c
onnectionInfo @{SSISCONFIG=".\SQLEXPRESS "}
  + CategoryInfo      : ObjectNotFound: (copy-isitemfiletosql:Stri ng) [], CommandNotFoundException
  + FullyQualifiedErrorId : CommandNotFoundException
copy-isitemfiletosql -path "\\pcna-02\mydocs\ltorres\My Documents\SSIS_Packages\PCSQ-02_test\*" -destination "msdb\Test" -destinationServer 'PCSQ-08' -connectionInfo @{SSISCONFIG=".\SQLEXPRESS"}
got this error
copy-isitemfiletosql -path "\\pcna-02\mydocs\ltorres\
The term 'copy-isitemfiletosql' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a p
ath was included, verify that the path is correct and try again.
At line:3 char:21
+ copy-isitemfiletosql <<<<Â -path "\\pcna-02\mydocs\ltorres\
onnectionInfo @{SSISCONFIG=".\SQLEXPRESS
  + CategoryInfo      : ObjectNotFound: (copy-isitemfiletosql:Stri
  + FullyQualifiedErrorId : CommandNotFoundException
add this before the command:
import-module SSIS
ASKER
Looks like there is an error copying here
I now get this error
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
I now get this error
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
ASKER
Looks like the SaveToDtsServer when this command is called
{ $app.SaveToDtsServer($pack age, $null, $path, $serverName) }
{ $app.SaveToDtsServer($pack
are you working with sql 2005 or 2008?
check his script here:
http://poshcode.org/1769
http://poshcode.org/1769
ASKER
I am working with 2008 the server its trying to import to is 2008
ASKER
Nah Same Error
PS C:\Users\ltorres> &Â 'C:\Users\ltorres\Download s\SQLPSX SSIS Demo.ps1'
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\ My Documents\SSIS_Packages\PC SQ-02_test \TEMPPKG" due to error
 0x80070
005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either pr
oviding
an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:725 char:27
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\ My Documents\SSIS_Packages\PC SQ-02_test \TESTING" due to error
 0x80070
005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either pr
oviding
an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:725 char:27
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\ My Documents\SSIS_Packages\PC SQ-02_test \PRODUCTIO N" due to er
ror 0x80
070005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either
 providi
ng an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:725 char:27
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
PS C:\Users\ltorres>
PS C:\Users\ltorres> &Â 'C:\Users\ltorres\Download
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\
 0x80070
005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either pr
oviding
an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\
 0x80070
005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either pr
oviding
an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "LoadPackage" with "2" argument(s): "Failed to open package file "\\pcna-02\mydocs\ltorres\
ror 0x80
070005 "Access is denied.". Â This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either
 providi
ng an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
"
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.LoadPackage <<<<Â ($path, $null) | add-Member -memberType noteProperty -name DisplayName -value $name -passthru }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
PS C:\Users\ltorres>
ASKER
Does This error
Exception calling "SaveToDtsServer" with "4" argument(s):
Is this an issue with the 4 Arguments
or an issue with the 4th Argument
$app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName)
The 4th Argument is the $ServerName
This is really getting frustrating Thanks for your help!
Exception calling "SaveToDtsServer" with "4" argument(s):
Is this an issue with the 4 Arguments
or an issue with the 4th Argument
$app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName)
The 4th Argument is the $ServerName
This is really getting frustrating Thanks for your help!
ASKER
In cased your wondering here is the code I ran. Do you see an issue?
#Edit SSIS.psm1 and Comment/Uncomment 2005 or 2008 version of SSIS assembly
#add-type -AssemblyName "Microsoft.SqlServer.ManagedDTS, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.ManagedDTS, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
#Import the SSIS module
import-module SSIS
#Work with SSIS packages stored on the file system
$packages = dir "\\pcna-02\mydocs\ltorres\My Documents\SSIS_Packages\PCSQ-02_test\*" | select -ExpandProperty Fullname | foreach {get-ispackage -path $_ }
$packages | foreach {$package = $_; $_.Configurations | Select @{n='Package';e={$Package.DisplayName}}, Name,ConfigurationString}
$packages | foreach {$package = $_; $_.Connections | Select @{n='Package';e={$Package.DisplayName}}, Name,ConnectionString}
#Create a new folder on the SSIS server
#new-isitem "\msdb" "sqlpsx" "Z002"
#Copy SSIS packages from the file system to SQL Server and change the connection string for SSISCONFIG
copy-isitemfiletosql -path "\\pcna-02\mydocs\ltorres\My Documents\SSIS_Packages\PCSQ-02_test\*" -destination "msdb\Test" -destinationServer "PCSQ-08" -connectionInfo @{SSISCONFIG=".\SQLEXPRESS"}
#Work with SSIS packages on SQL Server
$packages = get-isitem -path '\sqlpsx' -topLevelFolder 'msdb' -serverName "PCSQ-08" | where {$_.Flags -eq 'Package'} | foreach {get-ispackage -path $_.literalPath -serverName $_.Servername}
$packages | foreach {$package = $_; $_.Configurations | Select @{n='Package';e={$Package.DisplayName}}, Name,ConfigurationString}
$packages | foreach {$package = $_; $_.Connections | Select @{n='Package';e={$Package.DisplayName}}, Name,ConnectionString}
ASKER
any ideas?
what is the error?
ASKER
Exception calling "SaveToDtsServer" with "4" argument(s): "Unable to find the specified file."
At \\pcna-02\mydocs\ltorres\M y Documents\WindowsPowerShel l\Modules\ SSIS\SSIS. psm1:773 char:31
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
At \\pcna-02\mydocs\ltorres\M
+ Â Â Â Â { $app.SaveToDtsServer <<<<Â ($package, $null, $path, $serverName) }
  + CategoryInfo      : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
ASKER
ASKER
Is This some sort of set up issue?
ASKER
Updates?
ASKER
I am trying to put together a test environment so I can test