BIZTalk210 PowerScript的停止和启动发送端口(BIZTalk210 powers

2019-11-04 16:15发布

BIZTalk2010 PowerScript的停止和启动发送端口

我工作确定接收位置。 BizTalk2010重启接收位置每隔一小时

现在我需要做同样与发送端口。 但是,这是行不通的。

# a. Set Server name in ConnectionString -- 
# b. Set ($hostname) host name value that is using in SFTP send location
# c. Set ($sndLocation) send location name

$Catalog.ConnectionString ="xxx"
$hostname = "bbb"
$sndLocation = "SndPrt_XXXXXXX001" #send location

# Function to retrieve the status of the specify send port
function getStatus() {
    foreach ($sendPort in $catalog.SendPorts) {
        foreach($sendLoc in $sendPort.SendPorts 
                | Where {$_.Name -eq $sndLocation}) {
            return $sendLoc.enabled
        }
    }
}

# Function to enable the send port
function enablesendLocation() {
    $location = get-wmiobject MSBTS_SendPort -Namespace 
            'root\MicrosoftBizTalkServer' -Filter "name='${sndLocation}'"
    [void]$location.Start()
    [void]$Catalog.Refresh()
}

# Function to disable the send port
function disablesendLocation() {
    $location = get-wmiobject MSBTS_sendport -Namespace 
            'root\MicrosoftBizTalkServer' -Filter "name='${sndLocation}'"
    [void]$location.Stop()
    [void]$Catalog.Refresh()
}

{
    # Enable send location
    enablesendLocation
}

Answer 1:

解决的办法是

function getStatus(){

    foreach ($sendPort in $Catalog.SendPorts | Where {$_.Name -eq $sndLocation })
    {    
        return $sendPort.Status           
    } }

function enablesendLocation(){

    foreach ($sendPort in $Catalog.SendPorts | Where {$_.Name -eq $sndLocation })
    {    
        $sendPort.Status = 3
        $Catalog.SaveChanges()    
        $Catalog.Refresh()
    } }

function disablesendLocation(){

    foreach ($sendPort in $Catalog.SendPorts | Where {$_.Name -eq $sndLocation })
    {    
        $sendPort.Status = 2
        $Catalog.SaveChanges()    
        $Catalog.Refresh()
    } }


文章来源: BIZTalk210 powerscript to stop and start SEND PORT