Search code examples
powershellbiztalkbiztalk-ps1-provider

How can you delete a BizTalk receive port with a slash in the name using the PowerShell provider?


How can you delete a receive port when the name contains a slash?

I've got a receive port with a slash in its name, e.g. something like ... TestReceivePort/Service

When I try Remove-Item -Path "TestReceivePort/Service", I get an error that ...

Remove-Item : Cannot find 
              path BTS:\Applications\TestApp\Receive Ports\TestReceivePort\Service

Tried -LiteralPath, tried single quotes


Solution

  • Hopefully this will help:

    [void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
    $server = "."
    $connectionString = "SERVER=" + $server + ";DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"
    $Catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
    $Catalog.ConnectionString = $connectionString
    $rcvLocation =  $Catalog.ReceivePorts | Where {$_.Name = 'rcvLocation/withSlash'}
    $Catalog.RemoveReceivePort($rcvLocation)
    $Catalog.SaveChanges()