<#
.SYNOPSIS
<Delete Unwanted Host Instances on the specified BizTalk Server >
.DESCRIPTION
< you can delete the host instances that are not using , because host instances cause CPU and Memory Consumption>
.EXAMPLE
<Open the script in power Shell ISE with Run as Admin permission in the Any one of the BizTalk Web server and run it>
#>
[ARRAY]$hostInstanceObj = get-wmiobject MSBTS_HostInstance -namespace ‘root\MicrosoftBizTalkServer’ -Filter ‘RunningServer="Server1"’
[ARRAY]$HostInstanceObj1 = "Process_Host2","Archive_Host" # Provide the Unwanted Host Instances that you want to remove on the Server1
$hostInstances = $hostInstanceObj | ?{$HostInstanceObj1 -contains $_.hostname}
[ARRAY]$HostInfo = get-wmiobject MSBTS_ServerHost -namespace ‘root\MicrosoftBizTalkServer’ -Filter ‘ServerName="Server1"’
foreach ( $hostInstance in $hostInstances)
{
if ( $hostInstance.GetState().state -eq ‘4’)
{
Write-Output " stopping the Host name $($hostInstance.hostname)"
$hostInstance.InvokeMethod("Stop",$null)
}
if ( $hostInstance.GetState().state -eq ‘1’)
{
Write-Output " Deleting the Host name $($hostInstance.hostname)"
$hostInstance.InvokeMethod("UnInstall",$null)
foreach ( $hostrem in $HostInfo )
{
if ( $hostrem.hostname -eq $hostInstance.hostname)
{
$host2 = $hostrem
$host2.InvokeMethod("UnMap",$Null)
Write-Output " Unmapped the Host $($hostrem.hostname)"
}
}
}
}
Disclaimer : Please test in Lower environments before using this production . it Deletes the Host Instances that you mention