我是 PowerShell 新手,需要帮助。以下是检查 BizTalk 中主机实例状态的标准脚本。
我有两个任务: 1. 邮寄脚本的输出。2.调度PS脚本。
$servers = (".")
#This function checks the status of the host instances on a BizTalk server ($Server).
function checkhostinstancestatusstarted ($server)
{
#gets all host instances on the server. Isolated (hosttype = 2) or disabled hosts are excluded .
$hostinstances = get-wmiobject MSBTS_HostInstance -namespace 'root\MicrosoftBizTalkServer' | where {$_.runningserver -match $server -AND $_.hosttype -ne "2" -and $_.IsDisabled -ne "True"}
write-host "Checking the state of all host instances on the server $server`:"
foreach ($hostinstance in $hostinstances)
{
$HostInstanceName = $HostInstance.hostname
#Checks the host instance state
if ($HostInstance.ServiceState -eq 1)
{
write-host "$HostInstanceName`: Stopped."
}
elseif ($HostInstance.ServiceState -eq 2)
{
write-host "$HostInstanceName`: Start pending."
}
elseif ($HostInstance.ServiceState -eq 3)
{
write-host "$HostInstanceName`: Stop pending."
}
elseif ($HostInstance.ServiceState -eq 4)
{
write-host "$HostInstanceName`: Started."
}
elseif ($HostInstance.ServiceState -eq 5)
{
write-host "$HostInstanceName`: Continue pending."
}
elseif ($HostInstance.ServiceState -eq 6)
{
write-host "$HostInstanceName`: Pause pending."
}
elseif ($HostInstance.ServiceState -eq 7)
{
write-host "$HostInstanceName`: Paused."
}
elseif ($HostInstance.ServiceState -eq 8)
{
write-host "$HostInstanceName`: Unknown."
}
}
write-host `n
}
foreach ($server in $servers)
{
checkhostinstancestatusstarted $server
}