Wednesday, 22 February 2012 19:13

Installation script

Written by 
Rate this item
(2 votes)

Note: You can find a new version here

In my first series of blog posts I blogged about useful (sample) PowerShell scripts, working towards a simple BizTalk application deployment script. This script is now finished. You can download the script and the example xml-files below or here. The script does the following:
• Import the msi
• Import the binding file
• Install the msi
• Create directories
• Create event sources
• Restart host instances

The script only deploys BizTalk applications. It will fail if another version of the BizTalk application has already been installed or imported, so make sure that the application is not imported in BizTalk or installed on any BizTalk server.

This script makes use of the Microsoft.BizTalk.ExplorerOM. In BizTalk 2006 R2 and BizTalk 2009 the Microsoft.BizTalk.ExplorerOM is only supported to run as a 32-bits process. So be sure to use PowerShell 32-bit!

The script consists out of three files:

   1) The script itself

   2) An environment configuration file

   3) An installation configuration file

The script itself handles the installation logic. The environment configuration file contains all variables for a specific environment (e.g. test, production, etc.). The installation configuration file contains all the specific settings needed to deploy an application.

You will have to place the script on a BizTalk server in the BizTalk group where you want to deploy the application to. So, for example, if you have a test and production environment you will have to place the script on both environments.

Before you can use the deployment script you first have to edit the environment configuration file. The example xml-file should be pretty straightforward. There are some comments in the xml-file to explain some settings. Make sure you create the directories that are configured in the environment configuration file!

The second thing you have to do is to tell the script where it can find the environment configuration file. You will have to edit the following section in the script:

#>----------------------------------------------------------
#Input variables
$EnvironmentConfigFile = "C:\scripts\Deploy\EnvironmentConfiguration.xml"
#<----------------------------------------------------------

For every installation you will have to create installation configuration file. Most settings should be pretty straightforward as well, but some settings need some additional explanation. Sometimes a BizTalk application uses file directories to read and write files from. The script can create those directories. You can just add them under the tag CreateDirectories, like this:

<CreateDirectories>
    <CreateDirectory>C:\Temp\data\port1</CreateDirectory>
    <CreateDirectory>C:\Temp\data\port2</CreateDirectory>
    <CreateDirectory>C:\Temp\data\port3</CreateDirectory>
  </CreateDirectories>

If you do not need the script to create any directories just delete all the tags CreateDirectory, like this:

<CreateDirectories>
  </CreateDirectories>

The script can also create event sources. You can edit the event log sources like this:

<AddEventlogSources>
    <AddEventlogSource>
      <EventlogSource>BTSName</EventlogSource>
      <EventlogName>Application</EventlogName>
    </AddEventlogSource>
    <AddEventlogSource>
      <EventlogSource>BTSName</EventlogSource>
      <EventlogName>Application</EventlogName>
    </AddEventlogSource>
  </AddEventlogSources>

If you do not need to create event log sources you can edit the installation configuration file like this:

<AddEventlogSources>
  </AddEventlogSources>

After configuring everything mentioned above you are ready to start your first installation. Place all the files (MSI, binding file, installation configuration file) needed for the installation in the directory that is mentioned between the <DeliveryLocation> tags.

I hope you will find this script useful. If you have any questions, remarks or feature requests, please contact me. You can use the contact use page, twitter @jeroenhendr1ks / @bizadmblogging or LinkedIn.

P.s .

If you want to run the script your executionpolicy will have to be set to unrestricted, otherwise you will get an error. You can set the executionpolicy to unrestricted by using the following command:

set-executionpolicy unrestricted
Read 8867 times Last modified on Tuesday, 15 May 2012 10:01
Jeroen Hendriks

Jeroen Hendriks started his career in 2005 as a middleware administrator. One of the products he was responsible for was BizTalk Server 2004. Since that time he mainly focusses on designing, implementing and supporting BizTalk Server infrastructures. Currently he works as a consultant for Axon Olympus. He hopes that his day-to-day experiences will result in useful and practical blog posts. Among his certifications are MCTS BizTalk Server 2010, MCSA on Windows Server 2012, MCITP: Enterprise Administrator on Windows Server 2008, MCSA on SQL Server 2012, Database Administrator 2008 and Certified Ethical Hacker.

twitterlinkedin

Website: www.axonolympus.nl

2 comments

  • Comment Link Jeroen Hendriks Wednesday, 22 February 2012 19:26 posted by Jeroen Hendriks

    The installation script does not remove an older version. This means that you manually have to deinstall the old version. I would like to automate this process as well. I believe there are two solutions:
    1) If the script detects an old version, automatically remove it and continue installing.
    2) Create a separate deinstall script.

    What do you prefer and why?

  • Comment Link Lex Hegt Wednesday, 22 February 2012 20:05 posted by Lex Hegt

    I prefer option 2, because this keeps you in control, instead of the script.
    Maybe there is a good reason you don't want to uninstall the older version.

Login to post comments