Skip to content

Instantly share code, notes, and snippets.

@bat2001
bat2001 / Import_BRE_Policy_File.ps1
Created October 30, 2020 20:53
Import_BRE_Policy_File.ps1
param
(
[Parameter(Position=0,Mandatory=$true, HelpMessage="Path to biztalk resource, e.g. C:\BizTalkDeploy\Maps\1.0.0.10")]
[string]$resourcePath,
[Parameter(Position=1,Mandatory=$true, HelpMessage="list of files to import, separated by a comma, e.g. (BRE.1.60.xml,BRE.1.61.xml)")]
[string]$resourceNames
)
# Load necessary BizTalk assemblies
try
@bat2001
bat2001 / gist:7b4664a90e28476f246f
Last active August 29, 2015 14:07
PowerShell SQLSPX Create Config File Command
Get-PerfCounterCategory | where {$_.Category_Name -like '*BizTalk*'} | Get-PerfCounterInstance | Get-PerfCounterCounters | Save-ConfigPerfCounter -PathConfigFile c:\myouput.xml -NewFile
@bat2001
bat2001 / gist:99adf2444a7455aa5e8a
Created October 10, 2014 16:27
powershell SQLPSX command to get BizTalk performance counters
Get-PerfCounterCategory | where {$_.Category_Name -like '*BizTalk*'} | Get-PerfCounterInstance | Get-PerfCounterCounters | Format-List Machine_Name,Category_Name,Counter_Name,Counter_Type,Counter_Help | Out-File c:\myouput.txt
@bat2001
bat2001 / gist:8247385
Created January 3, 2014 21:54
XML change namespace on Xml.XmlDocument in C#
System.Xml.XmlDocument XMLOriginalDoc = new XmlDocument();
System.Xml.XmlDocument XMLFinalDoc = new XmlDocument();
// load an xml document with namespace to be changed. This example loads it from a file
XMLOriginalDoc.Load(openFileDialog1.FileName);
// Now load original document into new document, and modify namespace in the new document
XMLFinalDoc.LoadXml(XMLOriginalDoc.OuterXml.Replace(XMLOriginalDoc.DocumentElement.NamespaceURI, "http://MyNewNamespace"));
$arrInstancesSuspended = @()
foreach ($Row in $DataSet1.Tables[0].Rows)
{
$arrInstancesSuspended = $arrInstancesSuspended + (,($Row["ApplicationName"],$Row["InstanceID"]))
# Use format: $arrInstancesSuspended [0][0]
}
# Sort Array
$arrInstancesSuspended = $arrInstancesSuspended | Sort-Object @{Expression={$_[0]};Ascending=$true}
# Get unique apps
$unique_Application = $arrInstancesSuspended | foreach {$_[0]} | sort-object -unique
@bat2001
bat2001 / gist:6465222
Last active December 22, 2015 11:19
PowerShell SQL Setup
$SQLServer = 'yourBizTalkSQLServer'
$SQLDBName = 'BizTalkMsgBoxDb'
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; Integrated Security = True"
$SqlConnection.Open()
# Create SqlCommand object, define command text, and set the connection
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlQuery =`
"SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
SET deadlock_priority LOW
SELECT
nvcName AS ApplicationName,
uidInstanceID AS InstanceID,
nErrorCategory,
DATEADD(hh,-5,dtSuspendTimeStamp) AS DateSuspended, -- Subtract the appropriate hours for your timezone
nvcAdapter AS Adapter,
$hostInstances = get-wmiobject MSBTS_HostInstance -namespace 'root\MicrosoftBizTalkServer' | where {$_.runningserver -match $yourBTServerName}
foreach ($hostInstance in $hostInstances)
{
$hostInstanceName = $hostInstance.hostname
$hostInstanceServer = $hostInstance.RunningServer
#Checks the host instance state
switch ($HostInstance.ServiceState)
{
1 {$state = "Stopped"}
foreach($application in $catalog.Applications)
{
foreach ($orchestration in $application.Orchestrations)
{
$AppName = $application.Name
$OrchName = $orchestration.FullName
$OrchApp = $orchestration.Application
$OrchHost = $orchestration.Host
$OrchStatus = $orchestration.Status
}
foreach($port in $catalog.ReceivePorts)
{
foreach ($location in $port.ReceiveLocations)
{
$rxlocation = $port.ReceiveLocations
$locationname = $location.name
$locationapplication = $port.application.name
$locationstatus = $location.Enable
}
}