禁用BizTalk接收位置并停止主机实例完成时间::PowerShell脚本与BizTalk管理控制台



与从BizTalk管理员控制台执行相同任务相比,禁用接收位置和停止主机实例的PowerShell脚本花费了更多的时间。在我的环境中,我有200多个接收位置和主机实例。请参阅以下任务完成统计信息-

BizTalk管理控制台:禁用RL::大约2分钟,停止主机实例::大约5分钟

PowerShell脚本:禁用RL::30-40分钟,停止主机实例::大约30分钟

-----------禁用BizTalk接收位置---------------

$rcvLocations = get-wmiobject MSBTS_ReceiveLocation -Namespace 'rootMicrosoftBizTalkServer' -Filter {IsDisabled = "False"}
foreach($rcvLocation in $rcvLocations){ 
[void]$rcvLocation.Disable()
}

-------------停止BizTalk主机实例---------------

$hostInstances = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer' -Filter {HostType = 1 and ServiceState = 4 and IsDisabled = "False"} 
foreach($hostinstance in $hostInstances){ 
$hostinstance.Stop()
}

我会感谢你的!

如果我的任务在PowerShell脚本中的完成时间和Bts管理控制台中的接近。

也许是这样的,根据主机命名将like更改为您想要的任何模式。

$StartTime = $(get-date)
Start-Job -ScriptBlock {
$hostInstances = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer' -Filter {HostType = 1 and ServiceState = 4 and IsDisabled = "False" }
foreach($hostinstance in $hostInstances){ 
if ($hostinstance.HostName -Like "*Receiving*" -or $hostinstance.HostName -Like "*Clustered*")
{
$hostinstance.Stop()
}
}
}
Start-Job -ScriptBlock {
$hostInstances = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer' -Filter {HostType = 1 and ServiceState = 4 and IsDisabled = "False" }
foreach($hostinstance in $hostInstances){ 
if ($hostinstance.HostName -Like "*Sending*")
{
$hostinstance.Stop()
}
}
}

Start-Job -ScriptBlock {
$hostInstances = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer' -Filter {HostType = 1 and ServiceState = 4 and IsDisabled = "False" }
foreach($hostinstance in $hostInstances){ 
if ($hostinstance.HostName -Like "*Processing*")
{
$hostinstance.Stop()
}
}
}
While (Get-Job -State "Running")
{
Start-Sleep 10
}

$elapsedTime = $(get-date) - $StartTime
$totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks)
Write-Host "Total Time: $totalTime"

最新更新