BIZTalk210 powerscript to stop and start SEND PORT

▼魔方 西西 提交于 2019-12-11 18:27:03

问题


BIZTalk2010 powerscript to stop and start SEND PORT

I got the receive location working ok. BizTalk2010 restart Receive location every hour

Now I need to do the same with the send ports. But it does not work.

# 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
}

回答1:


The solution is

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()
    } }


来源:https://stackoverflow.com/questions/49678243/biztalk210-powerscript-to-stop-and-start-send-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!