Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Powershell - Modify Server Name in SQL 2005 SSIS Connections

By Mandeep Dulai,

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.

PREREQUISITES

  • 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.

 

REFERENCES

http://www.simple-talk.com/sql/database-administration/im-a-sql-server-dba,-and-im-in-love-with-powershell/?utm_source=simpletalk&utm_medium=email-main&utm_content=PowershellLove-20100614&utm_campaign=SQL
http://www.simple-talk.com/sysadmin/powershell/powershell-version-2-what-is-new-and-why-is-it-important/
http://www.sql-server-performance.com/2011/powershell-sql-server-example/
http://www.sqlservercentral.com/articles/powershell/73288/
http://sqlblog.com/blogs/jamie_thomson/archive/2011/02/02/export-all-ssis-packages-from-msdb-using-powershell.aspx
http://www.sqlservercentral.com/blogs/chadmiller/archive/2010/04/13/t_2D00_sql-tuesday-_2300_005_3A00_-ssis-reporting.aspx
http://blogs.technet.com/b/smsandmom/archive/2008/06/04/windows-powershell-basics-part-2.aspx
http://widba.blogspot.com/2011/04/ssis-package-versions-with-powershell.html
http://www.timvw.be/2011/03/12/some-powershell-functions-to-work-with-ssis-packages/
http://www.timvw.be/2010/11/11/update-configurationstrings-in-ssis-package-with-powershell/
http://billfellows.blogspot.com/2010/05/powershell-dtutil-ssisdeploymanifest.html
http://msdn.microsoft.com/en-us/library/cc281954.aspx
http://www.computerperformance.co.uk/powershell/powershell_variables.htm
http://www.w3schools.com/xpath/xpath_syntax.asp
http://www.sqlservercentral.com/articles/powershell/72051/

Total article views: 598 | Views in the last 30 days: 7
 
Related Articles
FORUM

Replace

How to replace a value

FORUM

Server Connection Timeout

Server Connection

FORUM

ISQLW Replacement

2005/8 deleted ISQLW.EXE small footprint utility with no real replacement

FORUM

changing the connection password hrough another package

changing the connection password through another package

FORUM

Urgent: Need Help to change server connection of SSIS packages

Need Help: For Changing server connection in SSIS for deploying into production without opening each...

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones