In this post, I will explain how to develop a PowerShell script to import multiple SSIS packages. You can use the script straight away to deploy the SSIS packages in any environment. I recommend that you to read all the steps in the script before you start using.
This set of scripts were developed and tested in order to automate SSIS packages migration from one environment to other.
Copy below script into notepad and save it as “Import-SSISPackages.ps1”
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
$SQLInstanceName,
[Parameter(Mandatory=$true)]
$PackageDir
)
FUNCTION Import-SSISPackages{
Param(
[string]$SQLInstanceName,
[string]$PackageDir
)
$CMD =$('for %I in (*.dtsx) do dtutil /FILE '+[char]34+'%I'+[char]34+' /COPY SQL;'+[char]34+'%~nI'+[char]34+' /DESTSERVER '+ $SQLInstanceName)
Start-Process CMD -ArgumentList "/k $CMD" -WorkingDirectory "$PackageDir" #-NoNewWindow
}
Import-SSISPackages $SQLInstanceName $PackageDir
Now, you are ready to start importing your ssis packages.
$SQLInstanceName is your destination sql server
$PackageDir is the directory name where all packages located.
Import-SSISPackages.ps1 $SQLInstanceName $PackageDir
Conclusion:
Above script makes it easy for us to not only import our ssis packages to SQL Server but automate the whole process as well.