Biztalk Health Check PowerShell script

Source: Internet
Author: User
Tags tmp folder biztalk

<#
. Synopsis
PowerShell script to perform a quick BizTalk health Check
. DESCRIPTION
This script gathers and displays a lot of information about a BizTalk server. Sections include Windows, computer, BizTalk artifacts, Event Logs and more.
important! The script would check the environment it ' s run from. This means if you run the script from a PROD server, it'll connect to the PROD BizTalk database.
. EXAMPLE
./biztalkhealthcheck.ps1
. NOTES
You need to IS member of BizTalk Server Administrators Group to run the this script. No parameters.
#>
Cls
$startTime = Get-date
Write-host "Collect date/time:" $startTime
Write-host "Current User:" ([System.security.principal.windowsidentity]::getcurrent (). Name)

try {# Get BizTalk information
$BizTalkGroup = Get-wmiobject Msbts_groupsetting-namespace root\microsoftbiztalkserver-erroraction Stop
$BizTalkMsgBoxDb = Get-wmiobject Msbts_msgboxsetting-namespace root\microsoftbiztalkserver-erroraction Stop
$BizTalkServer = Get-wmiobject Msbts_server-namespace root\microsoftbiztalkserver-erroraction Stop
$BizTalkREG = get-itemproperty "Hklm:\software\microsoft\biztalk server\3.0"-erroraction Stop
$hostInstances = Get-wmiobject Msbts_hostinstance-namespace root\microsoftbiztalkserver-erroraction Stop
$trackingHost = Get-wmiobject msbtshost-namespace root\microsoftbiztalkserver-erroraction Stop | where {$. Hosttracking-eq "true"}

$BizTalkDBInstance = $BizTalkGroup.MgmtDbServerName$BizTalkDB = $BizTalkGroup.MgmtDbName$BizTalkOM = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer$BizTalkOM.ConnectionString = "SERVER=$BizTalkDBInstance;DATABASE=$BizTalkDB;Integrated Security=SSPI"

}
catch {
Write-host "BizTalk not detected on the this machine, or user not member of BizTalk Administrators Group"-fore Red
Exit
}

Display BizTalk Information

Write-host "' Nbiztalk information"-fore Green
write-host $BiztalkREG. ProductName "(" $ Biztalkreg.productedition "Edition"
Write-host "Product Version:" $BiztalkREG. ProductVersion
Write-host " Installation Path: "$BiztalkREG. InstallPath
Write-host" installation Date: "$BiztalkREG. InstallDate
Write-host "Server name:" $BiztalkServer. name\
Write-host "SSO Server:" $BizTalkGroup. Ssoservername
Write-host "BizTalk Admin Group:" $BizTalkGroup. Biztalkadministratorgroup
Write-host "BizTalk Operators Group:" $ Biztalkgroup.biztalkoperatorgroup
Write-host "BizTalk Group Name:" $BizTalkGroup. Name
Write-host "Cache Refresh Interval: "$BizTalkGroup. Configurationcacherefreshinterval

Switch ($BizTalkGroup. globaltrackingoption) {
0 {write-host "Global Tracking:off"}
1 {write-host "Global Tracking:on"}
}
Write-host "' ninstalled BizTalk Software"-fore darkgray
Get-wmiobject Win32Product | Where-object {$. Name-like "BizTalk"} | Select-object Name-unique | Sort-object Name | Select-expand Name

Display BizTalk Host Instance Information

Write-host "' Nhost Instance information (" $hostInstances. Count ")"-fore Darkgray

foreach ($hostInstance in $hostInstances) {
Switch ($hostInstance. servicestate) {
1 {$hostInstanceState = "Stopped"}
2 {$hostInstanceState = "Start Pending"}
3 {$hostInstanceState = "Stop Pending"}
4 {$hostInstanceState = "Running"}
5 {$hostInstanceState = "Continue Pending"}
6 {$hostInstanceState = "Pause Pending"}
7 {$hostInstanceState = "Paused"}
8 {$hostInstanceState = "Unknown"}
}
Switch ($hostInstance. HostType) {
1 {$hostInstanceType = "in-process"}
2 {$hostInstanceType = "Isolated"}
}
if ($hostInstanceState-eq "Running") {
Write-host $hostInstance. Hostname "($hostInstanceType)" "-"-nonewline
Write-host $hostInstanceState-fore Green
}
ElseIf ($hostInstanceState-eq "Stopped") {
if ($hostInstance. Isdisabled-eq $true) {
Write-host $hostInstance. Hostname "($hostInstanceType)" "-"-nonewline
Write-host $hostInstanceState "(Disabled)"-fore Red
}
else {
Write-host $hostInstance. Hostname "($hostInstanceType)" "-"-nonewline
Write-host $hostInstanceState-fore Red
}
}
else {
if ($hostInstanceType-eq "in-process") {
Write-host $hostInstance. Hostname "($hostInstanceType)" "-"-nonewline
Write-host $hostInstanceState "(disabled:$ ($hostInstance. isdisabled))"-fore Darkyellow
}
else {
Write-host $hostInstance. Hostname "($hostInstanceType)"
}
}
}
Write-host "' ntracking Host (s)"-fore Darkgray
$trackingHost. Name

Get BizTalk Application Information

$applications = $BizTalkOM. Applications

Display BizTalk Application Information

Write-host "' Nbiztalk Applications (" $applications. Count ")"-fore Darkgray

Foreach ($application in $applications) {
if ($application. Status-eq "Started") {
Write-host $application. Name "-"-nonewline
Write-host $application. Status-fore Green
}
ElseIf ($application. Status-eq "Stopped") {
Write-host $application. Name "-"-nonewline
Write-host $application. Status-fore Red
}
else {
Write-host $application. Name "-"-nonewline
Write-host $application. Status-fore Darkyellow
}
}

Get BizTalk Service Instance Information

[ARRAY] $readyToRun = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceStatus = 1) '-erroraction silentlycontinue
[ARRAY] $active = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' (ServiceStatus = 2) and not (ServiceClass = +) '-erroraction silentlycontinue
[ARRAY] $dehydrated = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceStatus = 8) '-erroraction silentlycontinue
[ARRAY] $breakpoint = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceStatus = +) '-erroraction silentlycontinue
[ARRAY] $suspendedOrchs = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceClass = 1) and (ServiceStatus = 4 or servicestatus = +) '-erroraction silentlycontinue
[ARRAY] $suspendedMessages = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceClass = 4) and (ServiceStatus = 4 or servicestatus = +) '-erroraction silentlycontinue
[ARRAY] $suspendedRouting = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceClass = +) '-erroraction silentlycontinue
[ARRAY] $suspendedIsolated = get-wmiobject msbts_serviceinstance-namespace ' root\microsoftbiztalkserver '-filter ' ( ServiceClass = +) and (ServiceStatus = 4 or servicestatus = +) '-erroraction silentlycontinue

Display BizTalk Service Instance Information

Write-host "' Nservice Instance Information"-fore Darkgray
Write-host "Instances Ready to Run:" $readyToRun. Count
Write-host "Active Instances:" $active. Count
Write-host "dehydrated Instances:" $dehydrated. Count
Write-host "Instances in Breakpoint:" $breakpoint. Count
Write-host "Suspended orchestrations:" $suspendedOrchs. Count
Write-host "Suspended Messages:" $suspendedMessages. Count
Write-host "Routing failures:" $suspendedRouting. Count
Write-host "Isolated Adapter failures:" $suspendedIsolated. Count

Get and Display BizTalk Receive location information

[ARRAY] $recLocs = get-wmiobject msbtsreceivelocation-namespace ' Root\microsoftbiztalkserver ' | Where-object {$. Isdisabled-eq "true"}
Write-host "' Ndisabled Receive Locations (" $recLocs. Count ")"-fore Darkgray

if ($recLocs. count-gt 0) {$recLocs. Name}
else {write-host "None"}

Get and Display BizTalk Send Port Information

[ARRAY] $sendPorts = get-wmiobject msbtssendport-namespace ' Root\microsoftbiztalkserver ' | Where-object {$. Status-eq 2-or $_. Status-eq 1}
Write-host "' nstopped and unenlisted Send Ports (" $sendPorts. Count ")"-fore Darkgray

if ($sendPorts. count-gt 0) {$sendPorts. Name}
else {write-host "None"}

Get and Display orchstrations not started

[ARRAY] $orchs = get-wmiobject msbtsorchestration-namespace ' Root\microsoftbiztalkserver ' | Where-object {$. Orchestrationstatus-ne 4}
Write-host "' Nnot Started orchestrations (" $orchs. Count ")"-fore Darkgray

if ($orchs. Count-gt 0) {$orchs. Name}
else {write-host "None"}

Tracking

Write-host "' Ntracking"-fore darkgray
[ARRAY] $trackingSendPorts = get-wmiobject msbtssendport-namespace ' Root\microsoftbiztalkserver ' | Where-object {$. TRACKING-GT 0}
[ARRAY] $trackingRecPorts = get-wmiobject msbtsreceiveport-namespace ' Root\microsoftbiztalkserver ' | Where-object {$. TRACKING-GT 0}
Write-host "Receive Ports with Tracking:" $trackingRecPorts. Count
Write-host "Send Ports with Tracking:" $trackingSendPorts. Count

Get and Display Windows information

Write-host "' Nwindows Information"-fore Green
$windowsDetails = Get-wmiobject-class Win32_OperatingSystem
Write-host $windowsDetails. Caption
Write-host "Product Version:" $windowsDetails. Version
Write-host "Service Pack level:" $windowsDetails. csdversion
$UpdateSession = new-object-com Microsoft.Update.Session
$UpdateSearcher = $UpdateSession. CreateUpdateSearcher ()
$SearchResult = $UpdateSearcher. Search ("Isinstalled=0 and type= ' software '")
Write-host "Missing Windows Updates:" $SearchResult. Updates.count
Write-host "Architecture:" $windowsDetails. osarchitecture
Write-host "Installation Path:" $windowsDetails. WindowsDirectory
Write-host "page File:" (Get-wmiobject win32_pagefileusage). Name
Write-host "Temp Folder:" $env: Temp "(Get-childitem $env: Temp-file-recurse | Measure-object). Count "file (s))"
Write-host "tmp Folder:" $env: TMP "(" (Get-childitem $env: Tmp-file-recurse | Measure-object). Count "file (s))"
if (Test-path C:\temp) {
Write-host "C:\Temp:" (Get-childitem C:\temp-File-Recurse | Measure-object). Count "file (s)"
}

Import-module Servermanager
Get-windowsfeature | Where-object {$. Installed-eq $True} | Sort-object DisplayName | FT @{expression={$. DisplayName}; Label= "Installed Windows Roles and Features"}

Display IIS Information

try {
Import-module webadministration
Write-host "IIS Version:" (Get-itemproperty hklm:\software\microsoft\inetstp). setupstring
Write-host "' napplication pools"-fore darkgray-nonewline
Get-childitem Iis:\apppools | Ft-autosize
}
catch {
Write-host "Unable to perform IIS checks"-fore Red
}

Check Windows Service State,

function funccheckservice{
Param ($ServiceName)
$arrService = Get-service-name $ServiceName-erroraction silentlycontinue
if ($arrService. Status-eq "Running") {
Write-host $ServiceName "is running"
$script: unnecessaryservices++
}
}
Write-host ("unnecessary Windows Services")-fore Darkgray
[int] $script: unnecessaryservices = 0
Funccheckservice ("Print Spooler")
Funccheckservice ("Alerter")
Funccheckservice ("ClipBook")
Funccheckservice ("DHCP Server")
Funccheckservice ("Fax Service")
Funccheckservice ("File Replication")
Funccheckservice ("Infrared Monitor")
Funccheckservice ("Internet Connection sharing")
Funccheckservice ("Messenger")
Funccheckservice ("NetMeeting Remote Desktop sharing")
Funccheckservice ("Network DDE")
Funccheckservice ("Network DDE DSDM")
Funccheckservice ("NWLink NetBIOS")
Funccheckservice ("NWLink ipx/sp")
Funccheckservice ("Telephony")
Funccheckservice ("Telnet")
Funccheckservice ("uninterruptible Power Supply")
if ($unnecessaryServices-eq 0) {write-host "None"}

Display MSDTC Information

Write-host "' Nmsdtc Settings"-fore darkgray
Write-host "remoteclientaccessenabled:" (Get-dtcnetworksetting-dtcname Local). Remoteclientaccessenabled
Write-host "remoteadministrationaccessenabled:" (Get-dtcnetworksetting-dtcname Local). Remoteadministrationaccessenabled
Write-host "inboundtransactionsenabled:" (Get-dtcnetworksetting-dtcname Local). Inboundtransactionsenabled
Write-host "outboundtransactionsenabled:" (Get-dtcnetworksetting-dtcname Local). Outboundtransactionsenabled
Write-host "Authentication:" (Get-dtcnetworksetting-dtcname Local). AuthenticationLevel
Write-host "xatransactionsenabled:" (Get-dtcnetworksetting-dtcname Local). Xatransactionsenabled
Write-host "lutransactionsenabled:" (Get-dtcnetworksetting-dtcname Local). Lutransactionsenabled

Display Windows Firewall Information

Write-host "' Nwindows Firewall Status"-fore darkgray-nonewline
Get-netfirewallprofile | Select-object name,enabled | Ft-autosize

Get and Display application Event Log Information

Write-host "Most Common application Event Log Errors"-fore darkgray-nonewline
$eventLog = Get-eventlog-log Application-entrytype Error
$eventLog | Group-object-property Source-noelement | Sort-object-property Count-desc | Ft-autosize

Write-host "BizTalk related application Event Log Errors"-fore darkgray-nonewline
$BizTalkEventLog = Get-eventlog-log Application-entrytype Error | Where-object {$. Eventid-eq "5410"-or $. Source-like "BizTalk"-or $. Source-like "BAM"-or $. Source-like "DTC"-or $_. Source-like "ruleengine"} | Select-object Source,eventid,message-unique | Sort-object Message | Ft-autosize
$BizTalkEventLog

Get and Display Computer information

Write-host "Computer Information"-fore Green
$computerDetails = Get-wmiobject Win32_ComputerSystem
$drive = Get-wmiobject-class Win32_volume-filter "driveletter = ' C: '"
$defragReport = $drive. DefragAnalysis ()
Write-host "File System (C:):" $drive. FileSystem
Write-host "Capacity (C:):" ([Math]::round (($drive. capacity/1024/1024/1024), 0)) "GB"
Write-host "Fragmentation (C:):" $defragReport. Defraganalysis.filepercentfragmentation "%"
Write-host "Free Disk Space (C:):" $defragReport. Defraganalysis.freespacepercent "%"

Write-host "System Type:" $computerDetails. SystemType
Write-host "Physical RAM:" ([Math]::round (($computerDetails. TOTALPHYSICALMEMORY/1GB), 0)) "GB"
Write-host "domain:" $computerDetails. Domain
Write-host "Computer model:" $computerDetails. Model
Write-host "Computer manufacturer:" $computerDetails. Manufacturer
Write-host "BIOS Version:" (Get-wmiobject Win32_BIOS). Biosversion
Write-host "BIOS Serial Number:" (Get-wmiobject Win32_BIOS). serialnumber

$processors = Get-wmiobject Win32Processor
if (@ ($processors) [0]. NumberOfCores) {$cores = @ ($processors). Count * @ ($processors) [0]. NumberOfCores}
else {$cores = @ ($processors). Count}
$sockets = @ ($processors) |% {$
. Socketdesignation} | Select-object-unique). Count;

Write-host "' Nprocessor (s) and Load Percentage"-fore darkgray
foreach ($processor in $processors) {Write-host $processor. Name "(" $processor. Loadpercentage "%)"}
Write-host "Cores: $cores, Sockets: $sockets"

Write-host ("' Nanti-virus and Security Software")-fore Darkgray
$antiVirus = Get-wmiobject win32_product-filter "name like '%virus% ' or the name like '%defend% ' or the name like '%security% ' or Name like '%protect% ' "
if ($antiVirus. count-gt 0) {$antiVirus. Name}
else {write-host "None"}

Display Network Information

Write-host " nNetwork Information" -fore Green<br/>Write-Host "TCP ports in use:" (netstat -ano -p tcp).Count<br/>Write-Host " nnetwork Connections"-fore darkgray-nonewline
Get-netadapter | Select-object Name,status,linkspeed | Ft-autosize

$nics = get-wmiobject-computer localhost win32_networkadapterconfiguration-filter "ipenabled= ' true '"
Write-host "IP Address (es):"
$nics. IPAddress

foreach ($nic in $nics) {
Write-host "Description:" $nic. Description
Write-host "DHCP Server:" $nic. DHCPServer
Write-host "Default Gateway:" $nic. DefaultIPGateway
Write-host "MAC Address:" $nic. MACAddress
Write-host "NetBIOS over TCP/IP:"-nonewline
Switch ($nic. TcpipNetbiosOptions) {
0 {write-host "Enabled via DHCP"}
1 {write-host "Enabled"}
2 {write-host "Disabled"}
}
}

Write-host "' Ninternet Download Test"-fore darkgray
try {

Source Download URL
$source = "http://speedtest.newark.linode.com/100MB-newark.bin"# Destination download file$destination = $env:USERPROFILE + "\Downloads\Download.txt"# Download file$startDownloadTime = Get-DateInvoke-WebRequest $source -OutFile $destination -ErrorAction Stop$endDownloadTime = Get-Date$fileSize = ([Math]::Round(((Get-Item $destination).Length / 1024),0))$totalTime = ([Math]::Round($(($endDownloadTime-$startDownloadTime).TotalSeconds), 2))Write-Host "Download Time: $totalTime seconds"Write-Host "File Size: $fileSize KB"Write-Host "Download Speed:" ([Math]::Round(($fileSize / $totalTime), 2)) "KB/s"# Delete downloaded fileRemove-Item $destination

}
catch {
Write-host "Unable to perform Internet download speed test"-fore Red
}

Write-host "' Ndomain Controller time Sync"-fore Darkgray
try {
Import-module ActiveDirectory
$DC = Get-addomaincontroller-discover-erroraction Stop | Select-expand HostName
$TimeServer = w32tm/stripchart/computer: $DC/samples:5/dataonly
$TimeServer
}
catch {
Write-host "Unable to contact Domain Controller"-fore Red
}

$endTime = Get-date
Write-host "' Nscript Processing Time:" ([Math]::round ($ ($endTime-$startTime). Totalminutes), 2)) "Minutes"

Biztalk Health Check PowerShell script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.