On a current project I was working on, my task involved setting up a test environment which involved copying 60 SSIS packages from the production server to a test server. The problem at hand was the production server name was specified in the SSIS package connections and I did not want to go through each package manually and change the server name. Also, each package contained multiple connections including a connection to a DB2 production server. I'm a newbie to powershell and after reading many articles on the internet, I decided to automate the process using a powershell script.
- Install Powershell v2.0 - http://www.simple-talk.com/sysadmin/powershell/powershell-version-2-what-is-new-and-why-is-it-important/
- Install SQLPSX - http://www.sql-server-performance.com/2011/powershell-sql-server-example/
THE POWERSHELL SCRIPT
The powershell script takes a number of parameters:
$sourceSQLServerName: Production SQL Server to get a copy of SSIS packages
$destinationSQLServerName: Test SQL Server to load modified SSIS packages
$MSDBFolderName: Folder name within MSDB where SSIS packages are stored
$oldSQLServerName: Old SQL Server name that will be replaced by new name in SSIS package connections
$newSQLServerName: New SQL Server name that will replace old name in SSIS package connections
$oldDB2ServerName: Old DB2 Server name that will be replaced by new name in SSIS package connections
$newDB2ServerName: New DB2 Server name that will replace old name in SSIS package connections
$oldFileConnectionPath: Old file path that will be replaced by new file path in SSIS package connections
$newFileConnectionPath: New file path that will replace old file path in SSIS package connections
After the script is run, you can double check the modified SSIS packages which are copied to the local file system to verify connections were updated correctly.