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:
- BizTalk PowerShell – Restarting BTS Hosts
- BizTalk, Certificates and PowerShell
- Time saving PowerShell Snippets for BizTalk Part 1
- Using PowerShell in BizTalk Post-Processing Scripts
- BizTalk PowerShell Scripts
- Deployment script Part I - Kickoff
- Deployment script Part II - Combining file location and filename
- BizTalk Mapper: Custom Extension XML property fixed with PowerShell script (BizTalk 2010)
- How to obtain a list of “BizTalk Software Inventory” installed with PowerShell
- Change user credentials of a BizTalk Host Instance with PowerShell
- Change the startup type for BizTalk services to Automatic (Delayed Start) with PowerShell
- Enforce your tracking strategy with a PowerShell script
- Backup BizTalk applications and bindings script
- PowerShell script that get's BizTalk Server group settings
- How to get the status of host instances with PowerShell
- PowerShell - Microsoft.BizTalk.ExplorerOM
- Powershell: A one line script to terminate all BizTalk suspended messages
- How to configure SQL Server Network Protocols in the SQL Server that houses BizTalk Server databases with PowerShell
- Monitor your BizTalk environment using PowerShell – SQL Agent Jobs Monitoring
- Monitor your BizTalk environment using PowerShell – Disk Space Monitoring
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:
- BizTalk Server - Determine Version and Edition
- Powershell script to delete old files
- Determining the process ID of BizTalk Host Instances
- Powershell Script to automate deployment of BizTalk Application using BTDF
- Stop all applications
Other languages
This article is also available in other languages
See Also
Read suggested related topics:
- Windows PowerShell Getting Started Guide
- MSDN: PowerShell
- Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
- Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
- PowerShell Portal
- Wiki: Portal of TechNet Wiki Portals
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.