Share via


BizTalk Server Installation PowerShell Toolkit

Introduction

Installing and configuring BizTalk Server is not straightforward, is error prone and can take a lot of time. BizTalk MVPs and experts have created their own installation guides, which are very helpful. This toolkit consists of several PowerShell scripts, which are meant to automate installation and configuration steps.

Note!
  • This is not yet another installation guide. Use your favorite, and run the scripts in this toolkit as required
  • This guide is intended for professionals who want to automate several BizTalk installations steps. If you don't know the order the scripts should be run, for instance, please learn how to install BizTalk properly before running these scripts. This is not a one-click magical BizTalk installation script

How to Use

  • Download BizTalkInstallationToolkit.zip from TechNet Gallery
  • Copy ZIP-file to BizTalk and SQL servers, and unzip
  • Run scripts in Admin PowerShell console. Make sure PowerShell is not restricted

Details

This section will list all the script in the toolkit, and explain their purpose. All scripts are deliberately designed to do one thing only, to avoid complex error handling. Also, some scripts (like WindowsUpdate.ps1) need to be run several times. The scripts are listed alphabetically:

  • BAM_64bit.ps1
    The BAM portal only runs in 32-bit mode. If you are using Internet Information Services (IIS) in a 64-bit environment, you must set IIS to 32-bit mode to run the BAM portal. Run this script on all BizTalk servers in the group.

    Code

    cscript.exe c:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
    
  • BizTalkWindowsFeatures.ps1
    Several Windows features are required on BizTalk servers. This script will install them, and some optional ones. Run this script on all BizTalk servers in the group. If there are certain features you don't want on your servers, please comment them away in the script.
    Note! If Windows Server installation media is available on your server, comment away lines 2-6.

    Code

    01.# Set Windows installation media path
    02.$AlternateSourcePath = Read-Host("Enter path to installation media (e.g. D:\sources\sxs)")
    03. 
    04.# Create the Servicing Registry Key and LocalSourcePath String Value
    05.New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Servicing -Force
    06.Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Servicing -Name "LocalSourcePath" -Value $AlternateSourcePath -Force
    07. 
    08.Write-Host("")
    09.Write-Host("Installing Windows Features...") -Fore Green
    10. 
    11.# Install required Windows Features
    12.Import-Module ServerManager
    13.Install-WindowsFeature -name FS-FileServer
    14.Install-WindowsFeature -name Storage-Services
    15.Install-WindowsFeature -name Web-Default-Doc
    16.Install-WindowsFeature -name Web-Dir-Browsing
    17.Install-WindowsFeature -name Web-Http-Errors
    18.Install-WindowsFeature -name Web-Static-Content
    19.Install-WindowsFeature -name Web-Http-Logging
    20.Install-WindowsFeature -name Web-Log-Libraries
    21.Install-WindowsFeature -name Web-ODBC-Logging
    22.Install-WindowsFeature -name Web-Request-Monitor
    23.Install-WindowsFeature -name Web-Http-Tracing
    24.Install-WindowsFeature -name Web-Stat-Compression
    25.Install-WindowsFeature -name Web-Dyn-Compression
    26.Install-WindowsFeature -name Web-Filtering
    27.Install-WindowsFeature -name Web-Basic-Auth
    28.Install-WindowsFeature -name Web-Digest-Auth
    29.Install-WindowsFeature -name Web-Windows-Auth
    30. 
    31.Install-WindowsFeature -name Web-App-Dev -IncludeAllSubFeature
    32.Install-WindowsFeature -name Web-Mgmt-Tools -IncludeAllSubFeature
    33. 
    34.Install-WindowsFeature -name NET-Framework-Core
    35.Install-WindowsFeature -name NET-Framework-45-Core
    36.Install-WindowsFeature -name NET-Framework-45-ASPNET
    37.Install-WindowsFeature -name NET-WCF-HTTP-Activation45
    38.Install-WindowsFeature -name NET-WCF-TCP-PortSharing45
    39.Install-WindowsFeature -name RDC
    40.Install-WindowsFeature -name RSAT-AD-PowerShell
    41.Install-WindowsFeature -name RSAT-AD-AdminCenter
    42.Install-WindowsFeature -name RSAT-ADDS-Tools
    43.Install-WindowsFeature -name RSAT-ADLDS
    44.Install-WindowsFeature -name FS-SMB1
    45.Install-WindowsFeature -name PowerShell
    46.Install-WindowsFeature -name PowerShell-V2
    47.Install-WindowsFeature -name PowerShell-ISE
    48.Install-WindowsFeature -name WAS-Process-Model
    49.Install-WindowsFeature -name WAS-Config-APIs
    50.Install-WindowsFeature -name WoW64-Support
    
  • ComputerName.ps1
    If the computername is longer than 15 characters, BizTalk Configuration will not work. This script will check this for you, and allow you to change the name if required. Reboot is required. Run this script on all BizTalk servers in the group.

    Code

    $computerName = [system.environment]::MachineName
    $computerNameLength = $computerName.length
     
    # Valid computer name
    if ($computerNameLength -lt 16) {
        Write-Host("The computer name is $computerName, which is $computerNameLength characters.") -fore Green
        exit
    }
     
    # Invalid computer name
    else {
        Write-Host("The computer name is $computerName, which is $computerNameLength characters. It must be changed!") -fore Red
     
        $newComputerName = Read-Host("`nPlease enter a new computer name with maximum length of 15 characters")
     
        # New computer name is valid
        if (($newComputerName.Length -lt 16) -and ($newComputerName.Length -gt 0)) {
            try {
                # Domain computer
                if ((gwmi win32_computersystem).partofdomain -eq $true) {
                    $domainName = $env:userdomain + "\"
                    Rename-Computer -NewName $newComputerName -DomainCredential $domainName -Force
     
                # Workgroup computer
                } else {
                    Rename-Computer -NewName $newComputerName -Force
                }
            }
            catch {
                Write-Host("`nRename failed. Please update computer name manually.") -fore Red
                exit
            }
        }
        # New computer name is invalid
        else {
            Write-Host("`nComputer name must be maximum 15 characters. Exiting!") -fore Red
        }
    }
    
  • DisableIPv6.ps1
    IPv6 is the latest address protocol that will eventually replace IPv4. Windows Server 2012 R2 kept this protocol enabled by default, but it is also a fact that IPv6 is not yet common, and many routers, modems and other network equipment do not support it yet. It may therefore be a wise approach to disable it for now. Also by turning it off, it will facilitate the process of detecting which ports certain application are listening to. This script will list all network IPv6 connections, and allow you to disable connections by name. Run the script several times if necessary. Run this script on all servers.
    Note! This is an optional step. You have to decide if you want to keep IPv6 connections

    Code

    Write-Host("Current IPv6 network connections") -fore Green
    Get-NetAdapterBinding -ComponentID ms_tcpip6
    $netAdapterName = Read-Host("`nWhich IPv6 network name do you want to disable?")
    Disable-NetAdapterBinding -Name $netAdapterName -ComponentID ms_tcpip6
    
  • DownloadCAB.ps1
    BizTalk relies on diverse products and technologies to provide essential services and features. If not already present, some software that is required by BizTalk is installed on your computer during the BizTalk installation process. For example with BizTalk Server 2013 this software may be installed:

    • Microsoft SQL XML 4.0 with Service Pack 1
    • Microsoft Office Web Components
    • Microsoft ADO MD.Net 9.0
    • Microsoft ADO MD.Net 10.0

    This script will download the correct CAB-file, and put it in the user's Downloads folder. The user is prompted for BizTalk and Windows version. This script only needs to be run once. The CAB-file is used during BizTalk installation.

    Code

    <#
    .SYNOPSIS
    Download BizTalk Server prerequisite CAB-file (English)
    .DESCRIPTION
    This script downloads the prerequisite CAB-file for BizTalk Server. User is prompted for BizTalk and Windows version and bits
    .EXAMPLE
    ./DownloadBizTalkCAB.ps1
    .NOTES
    File will be downloaded in current user's Download folder
    #>
    cls
     
    # Get filename from URL
    function getfilename($source) {
        $pieces=$source.split("/") 
        $piecescount=$pieces.Count 
        $filename=$pieces[$piecescount-1] 
        return $filename
    }
     
    $BTversion = Read-Host("Which BizTalk version are you installing? Enter 2016, 2013R2, 2013, 2010, 2009 or 2006R2")
    $bits = 64
     
    # BizTalk Server 2016
    if ($BTversion -eq "2016") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2016, 2012R2, 10 or 8.1")
        switch ($winversion) {
            "2016" { $source = "http://download.microsoft.com/download/4/2/E/42E95EB2-5B2A-495F-A407-323799CE3FD2/BtsRedistW2K12R2EN64.CAB" }
            "2012R2" { $source = "http://download.microsoft.com/download/D/2/F/D2F133EC-9DA3-40E7-89E2-C7B5EBDC176A/BtsRedistW2K12R2EN64.CAB" }
            "10" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/1/9/E/19E8B896-2755-4C14-A01C-90BC4A2A4692/BtsRedistW2K12R2EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/5/5/4/554E1119-0E9D-46F5-8457-269575DAC657/BtsRedistWin81EN32.cab" }
                }
            }
            "8.1" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/A/4/F/A4FC6FD6-1F8D-4AF9-A148-A5205E605684/BtsRedistW2K12R2EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/C/D/1/CD183203-AC5F-409D-9EF8-C265D1725B85/BtsRedistWin81EN32.cab" }
                }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # BizTalk Server 2013R2
    elseif ($BTversion -eq "2013R2") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2012R2, 2012, 8.1 or 7")
        switch ($winversion) {
            "2012R2" { $source = "http://download.microsoft.com/download/4/D/A/4DA76382-88EC-46BD-85F1-785185004BE9/BtsRedistW2K12EN64.cab" }
            "2012" { $source = "http://download.microsoft.com/download/4/D/A/4DA76382-88EC-46BD-85F1-785185004BE9/BtsRedistW2K12EN64.cab" }
            "8.1" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/4/D/A/4DA76382-88EC-46BD-85F1-785185004BE9/BtsRedistWin8EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin8EN32.cab" }
                }
            }
            "7" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/4/D/A/4DA76382-88EC-46BD-85F1-785185004BE9/BtsRedistWin7EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin7EN32.cab" }
                }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # BizTalk Server 2013
    elseif ($BTversion -eq "2013") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2012R2, 2008R2, 8 or 7")
        switch ($winversion) {
            "2012" { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistW2K12EN64.cab" }
            "2008R2" { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistW2K8R2EN64.cab" }
            "8" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin8EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin8EN32.cab" }
                }
            }
            "7" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin7EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/2/7/C/27CE697C-9869-42DB-A22A-95B76DE842AE/BtsRedistWin7EN32.cab" }
                }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # BizTalk Server 2010
    elseif ($BTversion -eq "2010") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2008R2, 2008, 7 or Vista")
        switch ($winversion) {
            "2008R2" { $source = "http://download.microsoft.com/download/2/D/1/2D1B87F5-D9FF-40F4-BC56-B9B290C0E6B3/Bts2010Win2K8R2EN64.cab" }
            "2008" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "" }
                    32 { $source = "http://download.microsoft.com/download/F/7/7/F773381D-3AE6-4B25-91C1-A3424E272ABD/Bts2010Win2K8EN32.cab" }
                }
            }
            "7" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/5/2/0/520FFC0E-04F6-4143-BD66-AC0D96291F4B/Bts2010Win7EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/9/5/7/957242A4-63E1-4E91-81F1-ABDAC4FFD017/Bts2010Win7EN32.cab" }
                }
            }
            "Vista" { $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
                switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/E/E/2/EE2CB848-3669-4AAF-9941-22E370939496/Bts2010VistaEN64.cab" }
                    32 { $source = "" }
                }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # BizTalk Server 2009
    elseif ($BTversion -eq "2009") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2008, 2003, Vista or XP")
        $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
        switch ($winversion) {
            "2008" { switch ($bits) {
                    64 { $source = "" }
                    32 { $source = "http://download.microsoft.com/download/E/6/5/E65125DE-95B1-456E-A32E-54331C9D0CE0/BTSRedistW2K8EN32.cab" }
                 }
            }
            "2003" { switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/6/C/1/6C1723C0-576E-454E-AA86-A5D2AF9A6A27/BTSRedistW2K3EN64.cab" }
                    32 { $source = "" }
                 }
            }
            "Vista" { switch ($bits) {
                    64 { $source = "" }
                    32 { $source = "" }
                 }
            }
            "XP" { switch ($bits) {
                    64 { $source = "" }
                    32 { $source = "" }
                  }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # BizTalk Server 2006R2
    elseif ($BTversion -eq "2006R2") {
        $winversion = Read-Host("Which Windows version are you using? Enter 2003, Vista or XP")
        $bits = Read-Host("64 or 32-bit version of Windows? Enter 64 or 32")
        switch ($winversion) {
            "2003" { switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistW2k3EN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistW2k3EN32.cab" }
                 }
            }
            "Vista" { switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistVistaEN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistVistaEN32.cab" }
                 }
            }
            "XP" { switch ($bits) {
                    64 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistXpEN64.cab" }
                    32 { $source = "http://download.microsoft.com/download/e/d/8/ed897961-7213-4816-be92-9178bea8e5c0/BtsRedistXpEN32.cab" }
                  }
            }
            default { Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
                        exit }
        }
    }
    # Invalid Windows version
    else {
        Write-Host("`nInvalid or unsupported Windows version entered. Exiting") -fore Red
        exit
    }
    Write-Host("`nDownloading BizTalk Server $BTversion prerequisite CAB for Windows $winversion - $bits bit edition...") -Fore Green
     
    try {
        # Destination downloadfolder
        $destination = $env:USERPROFILE + "\Downloads\"
        $destination += getfilename $source
     
        # Download CAB-file
        Invoke-WebRequest $source -OutFile $destination
     
        Write-Host("`nFile download complete: " + $destination)
    }
    catch {
        Write-Host("`Download failed. Note that some URLs are not available, check the script source. If the URL is there, verify your Internet connection and try again.") -fore Red
        exit
    }
    
  • DownloadFiles.ps1
    Several tools and scripts are required (or useful) when configuring a BizTalk server. This includes

    This script will automatically download all these and put them in the user's Downloads folder. This script only needs to be run once.

    Code

    <#
    .SYNOPSIS
    Download BizTalk tools
    .DESCRIPTION
    This script downloads various BizTalk tools from the Internet
    .EXAMPLE
    ./DownloadFiles.ps1
    .NOTES
    File will be downloaded in current user's Download folder
    #>
    cls
     
    # Get filename from URL
    function getfilename($source) {
        $pieces=$source.split("/") 
        $piecescount=$pieces.Count 
        $filename=$pieces[$piecescount-1] 
        return $filename
    }
     
    $url = @()
    $localList = @()
    $fileList = @()
     
    # Array of URLs to tools
    $url += "http://download.microsoft.com/download/d/0/0/d00c8f6b-135d-4441-a97b-9de16a1935c1/DTCPing.exe"
    $url += "https://gallery.technet.microsoft.com/Registry-Settings-to-207c97e4/file/107914/1/MakeBizTalkOptimized.zip"
    $url += "https://gallery.technet.microsoft.com/Add-MSDTC-Port-range-to-c0a31d12/file/115472/1/DTCPorts.reg"
    $url += "http://download.microsoft.com/download/8/E/1/8E16A4C7-DD28-4368-A83A-282C82FC212A/MBSASetup-x64-EN.msi"
    $url += "https://download.microsoft.com/download/7/0/2/702CBC49-3162-4665-BDF8-CCEE51A972D3/BPA.zip"
    $url += "https://download.microsoft.com/download/6/D/3/6D38D0F5-9674-484D-B193-223CAF7EF984/BHMv4.1.zip"
    $url += "https://gallery.technet.microsoft.com/Pre-allocate-space-and-2f30403e/file/66311/1/SQLQuery2SetSpaceAndAutogrowthSettings.sql"
     
    # Get all filenames
    for($a=0;$a -lt $url.Count;$a++)
    {
        $fileList += getfilename $url[$a]
    }
     
    # Download all files
    for($b=0;$b -lt $url.Count;$b++)
    {
        $localList += $env:USERPROFILE + "\Downloads\" + $fileList[$b]
        Invoke-Command -scriptblock { Invoke-WebRequest $url[$b] -OutFile $localList[$b] }
    }
    
  • IIS-App-Pools.ps1
    This script will create one IIS App Pool for SOAP, and another for HTTP. These need to correspond to the Isolated Hosts in BizTalk. The user is prompted for AD-account and password. Run this script on all BizTalk servers running IIS.

    Code

    import-module webadministration
     
    # Get SOAP account details
    $SOAPusername = Read-Host("Please enter domain\username for SOAP app pool")
    $SOAPpassword = Read-Host("Please enter password for SOAP app pool")
     
    Write-Host("")
    Write-Host("Creating BizTalkSOAPAppPool...")  -Fore Green
     
    # Create SOAP app pool
    $SOAPappPoolName = "BizTalkSOAPAppPool"
    New-WebAppPool -Name $SOAPappPoolName -Force
    $SOAPappPool = Get-Item "IIS:\AppPools\$SOAPappPoolName"
    $SOAPappPool.processModel.identityType = 3
    $SOAPappPool.processModel.username = $SOAPusername
    $SOAPappPool.processModel.password = $SOAPpassword
    $SOAPappPool.managedRuntimeVersion = "v4.0"
    $SOAPappPool.managedPipeLineMode = "Integrated"
    $SOAPappPool | Set-Item
     
    # Get HTTP account details
    Write-Host("")
    $HTTPusername = Read-Host("Please enter domain\username for HTTP app pool")
    $HTTPpassword = Read-Host("Please enter password for HTTP app pool")
     
    Write-Host("")
    Write-Host("Creating BizTalkHTTPAppPool...")  -Fore Green
     
    # Create HTTP app pool
    $HTTPappPoolName = "BizTalkHTTPAppPool"
    New-WebAppPool -Name $HTTPappPoolName -Force
    $HTTPappPool = Get-Item "IIS:\AppPools\$HTTPappPoolName"
    $HTTPappPool.processModel.identityType = 3
    $HTTPappPool.processModel.username = $HTTPusername
    $HTTPappPool.processModel.password = $HTTPpassword
    $HTTPappPool.managedRuntimeVersion = "v4.0"
    $HTTPappPool.managedPipeLineMode = "Integrated"
    $HTTPappPool | Set-Item
    
  • MSDTC.ps1
    MSDTC is the Microsoft Distributed Transaction Coordinator. DTC provides the functionality to ensure complete transactions along with a distributed environment, which means across two or more networked computers. All multi-server installations of BizTalk include setup of MSDTC on the Windows servers. This also includes the SQL server(s). This script is meant for non-clustered installations. For more details about MSDTC in BizTalk installations, see this TechNet Gallery download.

    Code

    <#
    .SYNOPSIS
    Configure local MSDTC for BizTalk
    .DESCRIPTION
    This script configures MSDTC for BizTalk. Requires Windows 8.1/Server 2012 R2 and PowerShell 4.0 or newer
    .EXAMPLE
    ./MSDTC.ps1
    .NOTES
    Run the script on the servers that requires the configuration (BizTalk and SQL)
    #>
    cls
    # Enable MSDTC for Network Access
    Write-Host "Enabling MSDTC for Network Access..." –fore green
     
    try {
        Set-DtcNetworkSetting –DtcName Local –AuthenticationLevel Mutual –InboundTransactionsEnabled 1 –OutboundTransactionsEnabled 1 –RemoteClientAccessEnabled 1 –confirm:$false
     
        Restart-Service MSDTC
     
        Write-Host "`nMSDTC has been configured and restarted"
    }
    catch {
        Write-Host "MSDTC setup failed" -fore red
    }
    
  • SQLNetworkProtocols.ps1
    Under certain stress conditions (such as clients accessing SQL Server from the same computer), the SQL Server Shared Memory protocol may lower BizTalk Server performance. You can resolve this problem by disabling the use of the Shared Memory network protocol in SQL Server Network Configuration. Also, to facilitate transactions between SQL Server and BizTalk Server, you must enable TCP/IP and Named Pipes in SQL Server. This script will automate this. The user is prompted for SQL instance name. Run the script on the SQL server(s).

    Code

    import-module "sqlps"
    $smo = 'Microsoft.SqlServer.Management.Smo.'
    $wmi = new-object ($smo + 'Wmi.ManagedComputer').
     
    # Get instance
    $InstanceName = [System.String]$Args[0]
    if (!$InstanceName) {
        $InstanceName = Read-Host("Please enter SQL instance name (default is MSSQLSERVER)")
    }
     
    Write-Host("")
    Write-Host("Enabling TCP/IP...")  -Fore Green
     
    # Enable TCP/IP on the instance
    $uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='$InstanceName']/ServerProtocol[@Name='Tcp']"
    $Tcp = $wmi.GetSmoObject($uri)
    $Tcp.IsEnabled = $true
    $Tcp.Alter()
     
    Write-Host("")
    Write-Host("Enabling Named Pipes...")  -Fore Green
     
    # Enable Named Pipes on the instance
    $uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='$InstanceName']/ServerProtocol[@Name='Np']"
    $Np = $wmi.GetSmoObject($uri)
    $Np.IsEnabled = $true
    $Np.Alter()
     
    Write-Host("")
    Write-Host("Disabling Shared Memory....")  -Fore Green
     
    # Disable Shared memory on the instance
    $uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='$InstanceName']/ServerProtocol[@Name='Sm']"
    $Sm = $wmi.GetSmoObject($uri)
    $Sm.IsEnabled = $false
    $Sm.Alter()
     
    Write-Host("")
    Write-Host("Restarting SQL Server service...")  -Fore Green
     
    # Restart SQL Server service
    $service = get-service "$InstanceName"  
    restart-service $service.name -force 
     
    C:
    
  • SQLWindowsFeatures.ps1
    Several Windows features are required on SQL servers as well. This script will install them, and some optional ones. Run this script on all SQL servers. If there are certain features you don't want on your servers, please comment them away in the script.
    Note! If Windows Server installation media is available on your server, comment away lines 2-6.

    Code

    01.# Set Windows installation media path
    02.$AlternateSourcePath = Read-Host("Enter path to installation media (e.g. D:\sources\sxs)")
    03. 
    04.# Create the Servicing Registry Key and LocalSourcePath String Value
    05.New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Servicing -Force
    06.Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Servicing -Name "LocalSourcePath" -Value $AlternateSourcePath -Force
    07. 
    08.Write-Host("")
    09.Write-Host("Installing Windows Features...") -Fore Green
    10. 
    11.# Install required Windows Features
    12.Import-Module ServerManager
    13.Install-WindowsFeature -name FS-FileServer
    14.Install-WindowsFeature -name Storage-Services
    15.Install-WindowsFeature -name NET-Framework-Core
    16.Install-WindowsFeature -name NET-Framework-45-Core
    17.Install-WindowsFeature -name NET-WCF-HTTP-Activation45
    18.Install-WindowsFeature -name NET-WCF-TCP-PortSharing45
    19.Install-WindowsFeature -name RDC
    20.Install-WindowsFeature -name RSAT-SNMP
    21.Install-WindowsFeature -name FS-SMB1
    22.Install-WindowsFeature -name SNMP-WMI-Provider
    23.Install-WindowsFeature -name Telnet-Client
    24.Install-WindowsFeature -name PowerShell
    25.Install-WindowsFeature -name PowerShell-V2
    26.Install-WindowsFeature -name PowerShell-ISE
    27.Install-WindowsFeature -name WoW64-Support
    
  • StopPrintSpooler.ps1
    Unless you plan to print from your servers, disable the Print Spooler. It is enabled by default and is usually not required. Run this script on all servers.

    Code

    Get-Service Spooler | Stop-Service -PassThru | Set-Service -StartupType disabled
    Write-Host "Print Spooler has been stopped and disabled"
    
  • UpdateHelp.ps1
    Use this script to update all PowerShell Help files. Run this script on all servers. This task should also be done on a regular basis. For more details about updating PowerShell Help files, see this TechNet Gallery download.

    Code

    Update-Help
    
  • VerifyInstallation.ps1
    After BizTalk installation, you can verify that everything was installed successfully. This script will check Registry settings and Programs and Features. Run this on all BizTalk servers after installing BizTalk.

    Code

    # Get Registry entires
    Write-Host("Registry entries") -fore Green
    Get-ItemProperty "hklm:\SOFTWARE\Microsoft\BizTalk Server\3.0"
     
    # Get Programs and Features
    Write-Host("Programs and Features") -fore Green
    gwmi -class Win32_Product -Filter "name LIKE 'Microsoft BizTalk%'" | Select -expand Name
    
  • WindowsFirewall.ps1
    This script will open some Windows Firewall ports required for MSDTC, SQL communication and BizTalk360 (optional). This assumes you use the MSDTC port range Registry settings mentioned in DownloadFiles.ps1, and default ports in SQL Server. If you use other ports, please update the script accordingly. The user is prompted for BizTalk360 ports. Run this script even if Windows Firewall is disabled. Then it will still work if the firewall is enabled later. Run this script on all servers.

    Code

    $BT360 = Read-Host("Do you want to open ports for BizTalk360 (Y/N)?")
     
    Write-Host("")
    Write-Host("Opening and enabling ports for MSDTC and SQL...")  -Fore Green
     
    # Open ports for MSDTC
    New-NetFirewallRule -DisplayName "Allow MSDTC" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 135,5000-5100 | Out-Null
    New-NetFirewallRule -DisplayName "Allow MSDTC" -Direction Outbound -Action Allow -Protocol TCP -LocalPort 135,5000-5100 | Out-Null
     
    # Open ports for SQL
    New-NetFirewallRule -DisplayName "Allow SQL" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 1433-1434 | Out-Null
    New-NetFirewallRule -DisplayName "Allow SQL" -Direction Outbound -Action Allow -Protocol TCP -LocalPort 1433-1434 | Out-Null
     
    # Enable built-in MSDTC ports
    Enable-NetFirewallRule -DisplayName "Distributed Transaction Coordinator (RPC)" | Out-Null
    Enable-NetFirewallRule -DisplayName "Distributed Transaction Coordinator (RPC-EPMAP)" | Out-Null
    Enable-NetFirewallRule -DisplayName "Distributed Transaction Coordinator (TCP-In)" | Out-Null
    Enable-NetFirewallRule -DisplayName "Distributed Transaction Coordinator (TCP-Out)" | Out-Null
     
    if ($BT360.ToUpper() -eq "Y" -or $BT360.ToUpper() -eq "YES") {
        Write-Host("")
        Write-Host("Opening and enabling ports for BizTalk360...")  -Fore Green
     
        # Open ports for BT360
        New-NetFirewallRule -DisplayName "Allow BT360" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 135,1433,50000-50200,445,1164 | Out-Null
        New-NetFirewallRule -DisplayName "Allow BT360" -Direction Outbound -Action Allow -Protocol TCP -LocalPort 135,1433,50000-50200,445,1164 | Out-Null
    }
    
  • WindowsUpdate.ps1
    This script should be the first thing to be done after installing Windows. It also needs to be run after installing additional software. This script should be run on all servers. If run without parameters, the user is prompted before installing updates. There are two optional parameters - $Install and $Reboot. The first will ensure all updates are installed automatically, the second will automatically reboot the server (if required). Examples

    • ./WindowsUpdate.ps1 Y (automatically install updates)
    • ./WindowsUpdate.ps1 Y Y (automatically install updates, and reboot if required)

    Code

    [cmdletbinding()]
    param(
        [ValidateSet("Y", "Yes", "N", "No")]
        [Parameter(HelpMessage="Automatically install updates?")]
        [STRING]$Install,
        [ValidateSet("Y", "Yes", "N", "No")]
        [Parameter(HelpMessage="Automatically reboot when required?")]
        [STRING]$Reboot
    )
     
    cls
    # Create session and searcher
    $UpdateSession = New-Object -Com Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
      
    Write-Host("Searching for new updates...") -Fore Green
      
    $SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software'")
      
    # List all available updates
    Write-Host("")
    Write-Host("List of available updates:") -Fore Green
     
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
        $Update = $SearchResult.Updates.Item($X)
        Write-Host( ($X + 1).ToString() + " - " + $Update.Title)
    }
      
    # No updates available
    If ($SearchResult.Updates.Count -eq 0) {
        Write-Host("There are no available updates.")
        Exit
    }
     
    # Updates to download
    $UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl
      
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
        $Update = $SearchResult.Updates.Item($X)
        $Null = $UpdatesToDownload.Add($Update)
    }
     
    # Download updates 
    Write-Host("")
    Write-Host("Downloading Updates...")  -Fore Green
      
    $Downloader = $UpdateSession.CreateUpdateDownloader()
    $Downloader.Updates = $UpdatesToDownload
    $Null = $Downloader.Download()
     
    # Updates to install
    $UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
      
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
        $Update = $SearchResult.Updates.Item($X)
        If ($Update.IsDownloaded) {
            $Null = $UpdatesToInstall.Add($Update)        
        }
    }
      
    If (!$Install){
        $Install = Read-Host("Would you like to install these updates now? (Y/N)")
    }
      
    # Install updates
    If ($Install.ToUpper() -eq "Y" -or $Install.ToUpper() -eq "YES"){
        Write-Host("")
        Write-Host("Installing Updates...") -Fore Green
      
        $Installer = $UpdateSession.CreateUpdateInstaller()
        $Installer.Updates = $UpdatesToInstall
      
        $InstallationResult = $Installer.Install()
      
        Write-Host("")
        Write-Host("List of Installed Updates:") -Fore Green
      
        For ($X = 0; $X -lt $UpdatesToInstall.Count; $X++){
            Write-Host($UpdatesToInstall.Item($X).Title)
            Write-Verbose($UpdatesToInstall.Item($X).Title + ": " + $InstallationResult.GetUpdateResult($X).ResultCode)
        }
      
        Write-Host("")
     
        switch ($InstallationResult.ResultCode)
        {
            0 { Write-Host("Installation Result: Not Started") }
            1 { Write-Host("Installation Result: In Progress") }
            2 { Write-Host("Installation Result: Succeeded") }
            3 { Write-Host("Installation Result: Succeeded With Errors") -Fore Red }
            default { Write-Host("Installation Result: Succeeded") }
        }
         
        Write-Host("Reboot Required: " + $InstallationResult.RebootRequired)
      
        # Reboot required
        If ($InstallationResult.RebootRequire -eq $True){
            If (!$Reboot){
                $Reboot = Read-Host("Would you like to install these updates now? (Y/N)")
            }
      
            If ($Reboot.ToUpper() -eq "Y" -or $Reboot.ToUpper() -eq "YES"){
                Write-Host("")
                Write-Host("Rebooting...") -Fore Green
                (Get-WMIObject -Class Win32_OperatingSystem).Reboot()
            }
        }
    }
    

See Also

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.