Share via


BizTalk Server 2010: PowerShell

Introduction

Windows PowerShell is a Windows command-line shell designed especially for system administrators. It includes an interactive prompt and a scripting environment that can be used independently or in combination. PowerShell can be used by BizTalk administrators to help them in automating tasks. This can be done by creating scripts or commandlets or using for instance the PowerShell Provider BizTalk. In this article you find all necessary tools and resources to become proficient in using PowerShell in your BizTalk environment.

CodePlex

On CodePlex you can find the PowerShell Provider BizTalk. It is a project that allows you to administrate your BizTalk Server.

The project is divided into two components:

The BizTalkFactory PowerShell Provider is a PowerShell Snap-In for BizTalk Server 2006 R2, BizTalk Server 2009 and BizTalk Server 2010 that allows developers and administrators to easily automate routine and complex BizTalk administration tasks such as deploying applications, and managing configuration and run-time data using Windows PowerShell. Administrators can further increase productivity by leveraging the many cmdlets included with BizTalkFactory PowerShell Provider.

The PowerShell Provider BizTalk is not the only initiative on CodePlex. Another one is the PowerShell Tools for IT Admins. It is a PowerShell Module that allows you to control Microsoft BizTalk Server (2006+) via PowerShell.

Using PowerShell Scripts to restore BizTalk Databases

Configuring the backup job for BizTalk is a fairly simple task, while restoring it is a bit more complicated. By default the BizTalk backup job makes a full back up once a day, and a log backup every 15 minutes. When backups are done, a mark is set on each file. This mark is the same across all databases, and should be used to restore all databases to the same point in time and keeping all databases in a consistent state.

The only supported disaster recovery procedure from Microsoft is log-shipping. Although log-shipping comes with many advantages, it is still expensive since it requires a secondary SQL cluster.BizTalk doesn’t come with any restore scripts/features other than log-shipping. Hence Mikael Håkansson a BizTalk Server MVP has come up with the PowerShell scripts that will allow DBA's to restore the backup and log files created by the BizTalk jobs into a secondary SQL server, without the need for maintaining an expensive stand-alone SQL cluster.

The scripts can be downloaded from here http://blogical.se/blogs/mikael/archive/2011/02/22/powershell-cmdlet-for-biztalk-db-restore.aspx.

The sample comes with two cmdlet’s:
Get-Marks and New-RestoreDatabaseFromMark. The first one gives you a list of all marks from all log files. The second one, as the name implies, restores a database to a specific mark. When doing so, the database will be restored from the last full backup before the mark. After that, all log files will be restored in order from the full back up. The last log file will only be restored to the specified mark.

You can use the New-RestoreDatabaseFromMark cmdlet with or without specifying the mark. Leaving the mark empty is equivalent to last mark.

Blogs

CodePlex is not the only source, where you can find scripts. There are a couple of blog posts that provide you efficient PowerShell scripts:

MSDN Script Center

The Microsoft Script Center focuses on teaching people how to use Windows PowerShell and VBScript to reduce time spent performing mundane tasks. Through script center you can find many PowerShell scripts and a few on BizTalk:

Other languages

This article is also available in other languages

See Also

Read suggested related topics:

Another important place to find an extensive amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.