none
enable recieve location using powershell when MgmtDb is on diffrent server

    Question

  • Hi

    Can anybody please help me out how can I enable recieve location using powershell script, 

    where  Biztalk management DB is on another server and I dont have access to that server.

    I tried to use following script :

    [VOID][System.reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")
    
    $catalog=New-Object Microsoft.Biztalk.ExplorerOM.BtsCatalogExplorer
    
    $catalog.ConnectionString="Server=bt1234;Initial Catalog=BizTalkMgmtDb_DEV;Integrated Security=SSPI;"
    
    $catalog.RecievePorts|get-member


    But then got error staing 

    Get-Member : No object has been specified to the get-member cmdlet.
    At line:6 char:33

    Reallly need your help. I am beginner with Powershell and Biztalk.

    Friday, August 4, 2017 1:41 PM

Answers

  • Its working  now ,Mandar 

    .SaveChanges() did a magic.

    thanks a ton.

    But still question is why its not working with wmi Object and is it trustworthy to use ExplorerOM?


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    • Marked as answer by har Monday, October 16, 2017 1:47 PM
    Tuesday, August 22, 2017 7:38 AM
  • No, it did not worked.

    but then I used ExplorerOM to fix the issue for timebeing.

    Function EnableReceiveLocations
           {
            [System.reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")
            $bto=New-Object  Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
            $bto.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=."
            $rpColl = $bto.ReceivePorts
            foreach($rp in $rpColl)
            {
                $rlColl = $rp.ReceiveLocations
                foreach($rl in $rlColl)
                {
                    if($rl.Enable -eq $false)
                    {
                        $rl.Enable = $true
                        Write-Host('Receive Location'+ $rl.Name + ' enabled')
                    }
                    else
                    {
                        Write-Host('Receive Location'+ $rl.Name + ' already enabled')
                        
                    }
                }
            }
              $bto.SaveChanges() 
              $bto.Refresh()
           }
           
           
           
           EnableReceiveLocations
    If you get any workaround, please let me know. Thank you

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    • Marked as answer by har Monday, October 16, 2017 1:55 PM
    Monday, October 16, 2017 1:54 PM

All replies

  • 1. While you don't need physical or terminal access to the SQL Server, the account running the script needs the correct permissions in the BizTalk databases, such as BizTalk Server Administrators or BizTalk Server Operators.  There is no way around this.

    2. The WMI objects are the 'correct' way to manage BizTalk operations using scripts, including Powershell.

    This post includes an example of enabling a Receive Location using Powershell and WMI: https://www.codit.eu/blog/2013/09/25/tips-and-tricks-for-biztalk-monitoring-with-powershell/

    Friday, August 4, 2017 2:03 PM
    Moderator
  • thanks Johns

    I tried to run the following wmi-object command :

    $recievelocation = get-wmiobject MSBTS_RecieveLocation -namespace 'root\MicrosoftBiztalkServer' -Filter "name='rcv_xxx'"

    But got error class invalid:

    Get-WmiObject : Invalid class 
    At line:1 char:33
    + $recievelocation = get-wmiobject <<<<  MSBTS_RecieveLocation -namespace 'root\MicrosoftBiztalkServer' -Filter "name='rcv_xxx'"
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
        + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Friday, August 4, 2017 2:39 PM
  • You must have the BizTalk Administration Tools installed locally to run any BizTalk management script.  There is also no way around this.
    Friday, August 4, 2017 2:44 PM
    Moderator
  • I tried even this with computer name 
    get-wmiobject -class MSBTS_RecieveLocations -computername bt1234  -namespace 'root\MicrosoftBiztalkServer' -Filter "name='xxx'"
    But it says access denied :-(
    Friday, August 4, 2017 2:55 PM
  • Are you a member of BizTalk Server Administrators or BizTalk Server Operators?
    Friday, August 4, 2017 4:15 PM
    Moderator
  • Check if you can open the Biztalk Administration Console

    /Peter

    Friday, August 4, 2017 6:10 PM
  • Hi Peter,

    Yes, I can open Biztalk Admin Console.

    Wednesday, August 9, 2017 7:56 AM
  • Now I tried 

    $location=get-wmiobject -class MSBTS_ReceiveLocation   -namespace 'root\MicrosoftBiztalkServer' 
    $location

    And I am getting empty $location object

    :-(

    Wednesday, August 9, 2017 8:52 AM
  • Can anyone plz help me out with this?
    Wednesday, August 9, 2017 9:54 AM
  • $location = get-wmiobject msbts_receivelocation -Namespace ‘root\MicrosoftBizTalkServer’ -Filter "name='<my location>'"
    
    

    Should work, make sure you are on amachine with BizTalk intalled and use the correct user account

    Visual Studio Code is a nice tool and rich IDE for developing of PowerShell scripts

    /Peter

    Wednesday, August 9, 2017 10:15 AM
  • Thank you very much Peter for your reply.

    yes, I am using remote server where Biztalk is installed and I am in the Administrator group of that server.

    I can deploy the application in the Admin console it means I am a member of Biztalk Administrator group.

    I am using Powershell ISE(Isn't that enough)

    It's BT 2013, Windows server 2008 R2 standard and using VS Professional 2012

    its client server and we are not allowed to install anything I guess:-(

    • Edited by har Wednesday, August 9, 2017 10:47 AM
    Wednesday, August 9, 2017 10:39 AM
  • when I tried to run

    $hosts=get-wmiobject -class MSBTS_HOST -Namespace 'root\MicrosoftBizTalkServer' 
    $hosts

    its giving me the list of all hosts

    But when I am trying to run 

    get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -List
    

    its giving me just:

     NameSpace: ROOT\MicrosoftBizTalkServer

    Name                                Methods              Properties                                                                                                 
    ----                                -------              ----------                                                                                                 
    MSBTS_ReceiveLocation               {Enable, Disable}    {ActiveStartDT, ActiveStopDT, AdapterName, Caption...}    

     
    Wednesday, August 9, 2017 11:30 AM
  • Please ommit the "-List" parameter

    get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer'

    Above code gives me 6 receive locations 

    <All Artifacts> / Receive Locations also has 6 artifacts

    (local development server)

    NB! With "-List" the code does not return any receive locations

    - Peter

    Wednesday, August 9, 2017 11:43 AM
  • Hi, 

    I found out very strange thing 

    when I ran 

    $test=get-wmiobject -class MSBTS_ServerHost -Namespace 'root\MicrosoftBizTalkServer' 
    $test

    it gave me a list

    I tried 

    $test=get-wmiobject -class MSBTS_SendPort -Namespace 'root\MicrosoftBizTalkServer' $test

    It gave me list of all send port

    $t=get-wmiobject -class MSBTS_SendPortGroup -Namespace 'root\MicrosoftBizTalkServer' 
    $t

    It gave me list of send port group

    BUt when I tried

    $t=get-wmiobject -class MSBTS_ReceivePort -Namespace 'root\MicrosoftBizTalkServer' 
    $t
    
    $t=get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' 
    $t
    
    

    IT gave me nothing, what could be the reason

    Now I am exhausted :-(


    Wednesday, August 9, 2017 12:29 PM
  • WMI Class Reference for BizTalk
    https://msdn.microsoft.com/en-us/library/aa547120.aspx

    /Peter

    Wednesday, August 9, 2017 12:41 PM
  • Please help me on this....

    Wednesday, August 9, 2017 12:44 PM
  • Thank You peter,

    I am quite sure that I am using the correct cmdlet as its giving me output for other artifacts except for the recievePort and Receive Location

    Can you recognise why?

    Wednesday, August 9, 2017 12:51 PM
  • For the ones that work, look carefully at the output for the current MgmtDb to see if it's set properly.

    Wednesday, August 9, 2017 1:44 PM
    Moderator
  • For the ones that work, look carefully at the output for the current MgmtDb to see if it's set properly.

    tHANK you John

    I tried to run 

    $test1=get-wmiobject -class MSBTS_SendPortGroup -Namespace 'root\MicrosoftBizTalkServer' 
    $test1

    It gave me output with all properties.

    __GENUS              : 2
    __CLASS              : MSBTS_SendPortGroup
    __SUPERCLASS         : MSBTS_Setting
    __DYNASTY            : CIM_Setting
    __RELPATH            : MSBTS_SendPortGroup.MgmtDbNameOverride="BizTalkMgmtDb_DEV",MgmtDbServerOverride="bt1234",Name="SendGroupREAMToTEAM"
    __PROPERTY_COUNT     : 8
    __DERIVATION         : {MSBTS_Setting, CIM_Setting}
    __SERVER             : bt1234
    __NAMESPACE          : root\MicrosoftBizTalkServer
    __PATH               : \\bt1234\root\MicrosoftBizTalkServer:MSBTS_SendPortGroup.MgmtDbNameOverride="BizTalkMgmtDb_DEV",MgmtDbServerOverride="bt1234",Name="SendGro
                           upREAMToTEAM"
    Caption              : 
    Description          : 
    Filter               : <?xml version="1.0" encoding="utf-16"?>
                           <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                             <Group>
                               <Statement Property="BTS.MessageType" Operator="0" Value="http://one.xxx.com/servicebus/schemas/team/TeamCompanyASBO#CompanyASBO" />
                               <Statement Property="xxx.ServiceBus.App_Team.TeamCompanyASBO.requestedService" Operator="0" Value="REAMAccount" />
                             </Group>
                           </Filter>
    MgmtDbNameOverride   : BizTalkMgmtDb_DEV
    MgmtDbServerOverride : bt1234
    Name                 : SendGroupREAMToTEAM
    SettingID            : 
    Status               : 1

    This is what you mean?


    • Edited by har Thursday, August 10, 2017 7:01 AM
    Thursday, August 10, 2017 6:57 AM
  • And when I tried to run 

    [VOID][System.reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")
    
    $catalog=New-Object Microsoft.Biztalk.ExplorerOM.BtsCatalogExplorer
    $catalog.ConnectionString="Server=bt1234;Initial Catalog=BizTalkMgmtDb_DEV;Integrated Security=SSPI;"
    
    foreach($rcPort in $catalog.ReceivePorts | where {$_.Name -eq 'Receive_xxx'})
    {
      foreach($rcLocation in $rcPort.ReceiveLocations)
      {
        $rcPort.Name
        $rcLocation.Name
    
        $rcLocation.Enable     
       
      }
    }

    I am getting the result.

    It seems its only some glitch with the MSBTS_ReceivePort and MSBTS_ReceiveLocation

    Need your help...
    • Edited by har Thursday, August 10, 2017 7:21 AM
    Thursday, August 10, 2017 7:20 AM
  • You want all receive ports with name eq 'receive_*' and the corresponding receive locations, using WMI?

    Someone might be able to it a go :P

    /Peter

    Thursday, August 10, 2017 8:14 AM
  • No I want to enable and disable receivelocation and as Johns suggested wmi will be the best way to do it.

    The WMI objects are the 'correct' way to manage BizTalk operations using scripts, including Powershell.

    Thursday, August 10, 2017 8:26 AM
  • You should run using Invoke-command to run on remote computer (BizTalk Server where you want to enable the Receive Location):

    Invoke-command -ComputerName "Your_Remote_Server_Name" -ScriptBlock {     [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };     $recLocs[0].Enable();}



    • Edited by F.Mondelo Thursday, August 10, 2017 8:38 AM
    Thursday, August 10, 2017 8:36 AM
  • You should run using Invoke-command to run on remote computer (BizTalk Server where you want to enable the Receive Location):

    Invoke-command -ComputerName "Your_Remote_Server_Name" -ScriptBlock {     [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };     $recLocs[0].Enable();}



    when I tried to use above command . I got error stating check if machine is reachable over the network and firewall exception for windows Remote Management service is enabled.

    Thursday, August 10, 2017 8:50 AM
  • I couldnt get one thing if its aceess issue then Why I am able to get the values for sendPort and other artifacts but not only ReceivePort and ReceiveLocation.
    Thursday, August 10, 2017 8:52 AM
  • Hi HarC,

    Correct me if I am wrong

    You ran following for send port and got back the response

    $test1=get-wmiobject -class MSBTS_SendPortGroup -Namespace 'root\MicrosoftBizTalkServer' 
    $test1

    Then you ran 

    Invoke-command -ComputerName "Your_Remote_Server_Name" -ScriptBlock {     [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };     $recLocs[0].Enable();}

    You got that the error to check if the machine is reachable.

    IF my understanding is correct, then here is the reason why you get the error

    1) In case of the send port query using the wmi classes, the powershell looked for the wmi class for send port iz. MSBTS_SendPorts and thus fetches the data from the mgmtdb attached to the application server where you ran the script.

    2) Invoke command specifically asks the powershell script to be run onto the machine that you specify in the command. If the machine is not accessible then the script will not execute


    Mandar Dharmadhikari

    Thursday, August 10, 2017 9:34 AM
    Moderator
  • Thanks Mandar,

    yes When I ran 

    get-wmiobject -class MSBTS_SendPortGroup -Namespace 'root\MicrosoftBizTalkServer' 

    I got result,

    But did not get any for MSBTS_ReceiveLocation for the same server

    get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' 

    Thursday, August 10, 2017 10:12 AM
  • did you find any reason for this?

    Thursday, August 10, 2017 11:24 AM
  • Do you get the Receive Location list when running locally on the server?
    Thursday, August 10, 2017 1:43 PM
    Moderator
  • You should run using Invoke-command to run on remote computer (BizTalk Server where you want to enable the Receive Location):

    Invoke-command -ComputerName "Your_Remote_Server_Name" -ScriptBlock {     [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };     $recLocs[0].Enable();}



    when I tried to use above command . I got error stating check if machine is reachable over the network and firewall exception for windows Remote Management service is enabled.

    You enable Remote Administration on remote server? Execute this 

    winrm quickconfig

    on that server.

    Thursday, August 10, 2017 2:41 PM
  • You should run using Invoke-command to run on remote computer (BizTalk Server where you want to enable the Receive Location):

    Invoke-command -ComputerName "Your_Remote_Server_Name" -ScriptBlock {     [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };     $recLocs[0].Enable();}



    when I tried to use above command . I got error stating check if machine is reachable over the network and firewall exception for windows Remote Management service is enabled.

    You enable Remote Administration on remote server? Execute this 

    winrm quickconfig

    on that server.

    Thanks Mondelo,

    Actually I am running a script on a server where Biztalk is installed (but its MgmtDB is on another server, to which I dont have access).

    I dont think so its an access issue as I am able to get all send ports and other artifacts through the same wmi querry.

    What do you think?

    Friday, August 11, 2017 7:17 AM
  • Hi,

    I am trying to enable, disable receiveLocation using Powershell Script

    when I tried to access SendPort 

    $spg=get-wmiobject -class MSBTS_SendPort -Namespace 'root\MicrosoftBizTalkServer' | where-object {$_.Name -eq 'ToFile'}
    $spg.Stop()
    $spg.Start()

    I could start, stop and access all the sendPort.

    but when I tried 

    $rc=get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer'
    $rc

    I am getting the empty object.

    What could be the reason?

    Really need your help.

    Friday, August 11, 2017 7:36 AM
  • I think you are not checking well. The one that you are using is returning all the receive locations that are there in ur BT env.

    Are you running this in ur BizTalk server ?

    $rc=get-wmiobject -class MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer'
    $rc


    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool/

    Friday, August 11, 2017 7:55 AM
    Answerer
  • Maybe there are a mistake?
    Friday, August 11, 2017 8:03 AM
  • Yes, I am running on the same server where I am running a querry for sendPort.

    Its not returning me any receiveLOcation I am getting an empty object. :-(

    Friday, August 11, 2017 8:09 AM
  • Maybe there are a mistake?
    I couldn't find any :-( Can you?
    Friday, August 11, 2017 8:13 AM
  • This is the script to enable a Receive Location:

    [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.Name -eq "YourReceiveLocationName" };

    $recLocs[0].Enable();

    Friday, August 11, 2017 8:20 AM
  • This is the script to enable a Receive Location:

    [ARRAY]$recLocs =

     get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer'

    | Where-Object {$_.Name -eq "YourReceiveLocationName" };

    $recLocs[0].Enable();

    Yess, Tried its not working as I am not gettting any receiveLocation after this 

     get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer'
    But its working for SendPort and SendPortGroup

     get-wmiobject MSBTS_SendPort -namespace 'root\MicrosoftBizTalkServer'


    • Edited by har Friday, August 11, 2017 8:26 AM
    Friday, August 11, 2017 8:25 AM
  • No any update on this :-(

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 15, 2017 11:09 AM
  • Let's sum up the thread

    We have verified 

    1. On the same computer where you tried to run the powershell script you can open the Biztalk Administration Console and view and change Receive Ports/Locations? (please correct if wrong assumption)
    2. Shown Powershell/WMI code is the way to get object properties for the receive locations

    Questions

    1. What version of BizTalk are you using
    2. Are all BizTalk databases located on the same SQL server or are they split out to different SQL servers?
    3. You have no Access to the SQL server, I assume by Remote Desktop
      Can you get access to BizTalkMgmtDb thrugh SQL Server Enterprise Manager from the computer where you run the scripts

    /Peter

    Tuesday, August 15, 2017 11:40 AM
    1. On the same computer where you tried to run the powershell script you can open the Biztalk Administration Console and view and change Receive Ports/Locations? (please correct if wrong assumption)--->True

    1. What version of BizTalk are you using-->Microsoft Biztalk Server 2013
    2. Are all BizTalk databases located on the same SQL server or are they split out to different SQL servers-->yes, all BiztalkMgmtDB, BiztalkMsgBoxDb and BiztalkDTADb located on the same server , SSODB and Rule Engine Database is also on the same server
    3. You have no Access to the SQL server, I assume by Remote Desktop--->True
      Can you get access to BizTalkMgmtDb thrugh SQL Server Enterprise Manager from the computer where you run the scripts---->MSS Management studio is not installed on the server 

    Thank you for the help






    • Edited by har Wednesday, August 16, 2017 7:59 AM
    Wednesday, August 16, 2017 7:54 AM
  • Are you allowed to install MSSMS on the BizTalk Server?

    We need to establish if you problems are caused by missing user rights

    I assume that all biztalk databases are installed on the same SQL server?

    This script runs nicely on our BTS 2013 Dev setup (BTS and MSSQL on seperate server)
    It is run directly on the BTS server under my own domain account

    # Get and Display BizTalk Receive Location Information
    [ARRAY]$recLocs = get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' | Where-Object {$_.IsDisabled -eq "true" }
    Write-Host "`nDisabled Receive Locations (" $recLocs.Count ")" -fore DarkGray
     
    if ($recLocs.Count -gt 0) { $recLocs.Name }
    else { Write-Host "None" }


    Script is part of a series of Health Check scripts on TechNet
    https://social.technet.microsoft.com/wiki/contents/articles/32946.biztalk-server-health-check-powershell-script.aspx

    /Peter


    Wednesday, August 16, 2017 8:09 AM
  • NO I am not allowed to instal SSMS on the Biztalk server.


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Wednesday, August 16, 2017 8:41 AM
  • I cant get it, I can SendPort and SendPortGroup but cant ReceivePort and ReceiveLocation :-(

    I tried to run the script in Windows Powershell ISE(x86), No success :-(

    (Though I can see many receiveLocations and Port in the Admin console)

    Is there any another way to cross check?

    I tried even to enable and disable it using ExplorerOM but it dint help at all :-(






    • Edited by har Wednesday, August 16, 2017 8:55 AM
    Wednesday, August 16, 2017 8:45 AM
  • I assume my latest code sample does not work as expected?

    /Peter

    Wednesday, August 16, 2017 9:52 AM
  • this wasn't working since begining :-(

     get-wmiobject MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer' 

    Doesnt work

    but 

     get-wmiobject MSBTS_SendPort -namespace 'root\MicrosoftBizTalkServer' 
    works as expeted

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Wednesday, August 16, 2017 10:31 AM
  • I am quite sure it's an issue with user access rights, it might be related to WMI as you can access the receive location properties in the BTS Console

    Do you have another user account or colleague with elevated (administrator) access to the BizTalk Server who can help you test my assumption?

    If this test is unsuccessfull you might have a defect installation, you need to examine this further

    /Peter

    Wednesday, August 16, 2017 10:47 AM
  • If its access rights , then why can I sendPort?

    Correct me if I am wrong.


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Wednesday, August 16, 2017 11:27 AM
  • Hi har c,

    It looks like there is some issue with mof provider that you have in the Biztalk install directory. Can you check if the BTSWMISchemaXP.mof (It should be in the install directory of BizTalk) has entry for the class MSBTS_ReceiveLocation?? May be it got corrupted

    you can check out below mentioned article.

    https://blogs.technet.microsoft.com/askperf/2009/04/13/wmi-rebuilding-the-wmi-repository/ 

    The article highlights the same invalid class error that you mentioned above. 

    Note: I would caution you to not run the commands in the article without proper understanding of them. The link shared is for your understanding if it is same issue as yours

    Also if the wmi class is not helpful you can use the Explorer namespace  with powershell


    Mandar Dharmadhikari


    Thursday, August 17, 2017 3:06 AM
    Moderator
  • Thank you Mandar,

    I could find a class MSBTS_ReceiveLocation  in BTSWMISchemaXP.mof

    [Dynamic,Provider("MicrosoftBizTalkServer") : ToInstance,SupportsCreate,SupportsDelete,SupportsUpdate] 
    class MSBTS_ReceiveLocation : MSBTS_Setting
    {
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass] string Name;
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,write : ToSubclass] string MgmtDbNameOverride = "";
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,write : ToSubclass] string MgmtDbServerOverride = "";
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,write : ToSubclass] string ReceivePortName;
      [read : ToSubclass,write : ToSubclass] string AdapterName;
      [read : ToSubclass,write : ToSubclass] string PipelineName;
      [read : ToSubclass,write : ToSubclass] string InboundTransportURL;
      [read : ToSubclass,write : ToSubclass] string InboundAddressableURL;
      [read : ToSubclass,write : ToSubclass] string HostName;
      [read : ToSubclass,write : ToSubclass] boolean StartDateEnabled = FALSE;
      [read : ToSubclass,write : ToSubclass] datetime ActiveStartDT;
      [read : ToSubclass,write : ToSubclass] boolean StopDateEnabled = FALSE;
      [read : ToSubclass,write : ToSubclass] datetime ActiveStopDT;
      [read : ToSubclass,write : ToSubclass] boolean OperatingWindowEnabled = FALSE;
      [read : ToSubclass,write : ToSubclass] datetime SrvWinStartDT;
      [read : ToSubclass,write : ToSubclass] datetime SrvWinStopDT;
      [read : ToSubclass] boolean IsDisabled = TRUE;
      [read : ToSubclass,write : ToSubclass] string CustomCfg;
      [read : ToSubclass] boolean IsPrimary = FALSE;
      [read : ToSubclass,write : ToSubclass] String SendPipeline = "";
      [read : ToSubclass,write : ToSubclass] String EncryptionCert = "";
      [read : ToSubclass,write : ToSubclass] String SendPipelineData = "";
      [Implemented] uint32 Enable();
      [Implemented] uint32 Disable();
    };

    And Class for MSBTS_ReceivePort as well:

    [Dynamic,Provider("MicrosoftBizTalkServer") : ToInstance,SupportsCreate,SupportsDelete,SupportsUpdate] 
    class MSBTS_ReceivePort : MSBTS_Setting
    {
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,WriteAtCreate] string Name;
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,write : ToSubclass] string MgmtDbNameOverride = "";
      [key : ToInstance ToSubclass DisableOverride,read : ToSubclass,write : ToSubclass] string MgmtDbServerOverride = "";
      [read : ToSubclass,WriteAtCreate] boolean IsTwoWay;
      [read : ToSubclass,write : ToSubclass] string PrimaryReceiveLocation;
      [read : ToSubclass,write : ToSubclass] string SendPipeline;
      [read : ToSubclass,write : ToSubclass] uint32 Tracking;
      [read : ToSubclass,write : ToSubclass] string OutboundTransforms;
      [read : ToSubclass,write : ToSubclass] string InboundTransforms;
      [read : ToSubclass,write : ToSubclass] boolean RouteFailedMessage = FALSE;
    };

    Explorer namespace is not helping me :-(

    I tried like this:

    [Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")
    $Catalog= New-Object Microsoft.Biztalk.ExplorerOM.BtsCatalogExplorer
    
    $Catalog.ConnectionString="SERVER=bt1234;DATABASE=BiztalkMgmtDB_DEV;Integrated Security=SSPI"
    foreach($rcPort in $Catalog.ReceivePorts|where-Object {$_.Name -eq 'XXX'})
    {
       foreach($rcLocation in $rcPort.ReceiveLocations)
       {
          $rcLocation.Enable
          $rcLocation.Enable = $True
          $Catalog.Refresh()
          $rcLocation.Enable
       }
    }

    When I ran winmgmt /verifyrepository

    I got WMI repository is consistent.

    :-)

    I think its not corrupted then.


    • Edited by har Thursday, August 17, 2017 8:46 AM
    Thursday, August 17, 2017 7:04 AM
  • The article highlights the same invalid class error that you mentioned above.

    Now I am not getting any error , Its just an empty ReceiveLocation Object (not able to retreive receiveLocation and ReceivePOrt using wmiobject)

     that error was due to spell mistake in Receive but then I corrected it and did not get any error after that.



    • Edited by har Thursday, August 17, 2017 7:50 AM
    Thursday, August 17, 2017 7:49 AM
  • Still couldn't find an answer :-(

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Monday, August 21, 2017 8:02 AM
  • The MSBTS_ReceiveLocation WMI class wraps the Microsoft.BizTalk.ExplorerOM.ReceiveLocation class

    If you can use ExplorerOM your WMI is broken
    Check on how to rebuild the WMI

    Do you only have one BizTalk Server? No development or QA systems?

    /Peter

    Monday, August 21, 2017 10:52 PM
  • no there is server ecosystem have dev, sit, uat and production servers.

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 6:39 AM
  • Hi Har,

    I agree with Peter here, there seems to be some issue with the WMI class. To reconfirm the same, might I request you to run the same script on some other BizTalk box and check if there is same problem( I am pretty sure it will not be a problem on other machines), if it happens on only one machine, then I would suggest you go for a repair of BizTalk environment and see if that fixes the issue.

    In the mean time, find the below powershell script which uses the explorer om namespace classes and enables the receive locations. It goes to receive locations port by port and enables only those which are disabled. The script itself is crude right now and you may want to refine it a little bit to suit your needs. But it does enable the receive locations.

           Function EnableReceiveLocations
           {
                [System.Reflection.Assembly]::LoadFile("C:\Windows\assembly\GAC_MSIL\Microsoft.BizTalk.ExplorerOM\3.0.1.0__31bf3856ad364e35\Microsoft.BizTalk.ExplorerOM.dll")
            $bto=New-Object  Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
            $bto.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=."
            $rpColl = $bto.ReceivePorts
            foreach($rp in $rpColl)
            {
                $rlColl = $rp.ReceiveLocations
                foreach($rl in $rlColl)
                {
                    if($rl.Enable -eq $false)
                    {
                        $rl.Enable = $true
                        Write-Host('Receive Location'+ $rl.Name + ' enabled')
                    }
                    else
                    {
                        Write-Host('Receive Location'+ $rl.Name + ' already enabled')
                        
                    }
                }
            }
              $bto.SaveChanges() 
              $bto.Refresh()
           }
           
           
           
           EnableReceiveLocations

    Now if this script doesnot work for you then  there is something definitely wrong in the environment on which you are working. Try a BizTalk repair and see if that helps.


    Mandar Dharmadhikari


    Tuesday, August 22, 2017 6:45 AM
    Moderator
  • The MSBTS_ReceiveLocation WMI class wraps the Microsoft.BizTalk.ExplorerOM.ReceiveLocation class

    If you can use ExplorerOM your WMI is broken
    Check on how to rebuild the WMI

    Do you only have one BizTalk Server? No development or QA systems?

    /Peter

    According to this:https://support.quest.com/vworkspace/kb/88861

    winmgmt /verifyrepository  -->if gives inconsistent then its broken, but as mentioned earlier its giving me result as WMI repository isconsistent


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 6:45 AM
  • HI Har,

    have you tried running  wmi the script onto some other environment? does it work? have you tried the script that I shared?


    Mandar Dharmadhikari


    Tuesday, August 22, 2017 6:55 AM
    Moderator
  • Thanks Mandar,

    actually I am not able to retreive Receive location in any env. i.e. neighther dev nor test.

    I tried to run your above script getting an error : 

    Exception calling "LoadFile" with "1" argument(s): "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"
    At line:1 char:1
    + [System.Reflection.Assembly]::LoadFile("C:\Windows\assembly\GAC_MSIL\Microsoft.B ..

    There is no folder called GAC_MSIL under assembly folder.


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer


    • Edited by har Tuesday, August 22, 2017 7:13 AM
    Tuesday, August 22, 2017 7:09 AM
  • HI har you can try following instead of Load file method

    [System.reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")


    Mandar Dharmadhikari

    Tuesday, August 22, 2017 7:19 AM
    Moderator
  • Its working  now ,Mandar 

    .SaveChanges() did a magic.

    thanks a ton.

    But still question is why its not working with wmi Object and is it trustworthy to use ExplorerOM?


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    • Marked as answer by har Monday, October 16, 2017 1:47 PM
    Tuesday, August 22, 2017 7:38 AM
  • As stated the WMI classes uses ExplorerOM to automate BTS
    Also the BizTalk Administration Console uses ExplorerOM

    Is WMI no working on any of the servers or you not able to test the WMI script onother servers?

    /Peter

    Tuesday, August 22, 2017 7:44 AM
  • Hi Har,

    You can use the ExplorerOM , only thing you need to keep in mind is that in case explorer om encounters a exception, all the changes are rolled back, meaning the SAVE doesnot function in case of  exception, but there should not be a case for exception in this as far as I know. If there is any issues with the receive location being not enabled, you can always refer the windows event log for the error.

    AS far as the WMI goes, I think, you need to do a check on other environment and see if the same code runs, which it will, I would suggest a repair of the environment if possible.

    If you think the question is answered  then I would request you to close the thread.


    Mandar Dharmadhikari


    Tuesday, August 22, 2017 7:46 AM
    Moderator
  • As stated the WMI classes uses ExplorerOM to automate BTS
    Also the BizTalk Administration Console uses ExplorerOM

    Is WMI no working on any of the servers or you not able to test the WMI script onother servers?

    /Peter

    WMI is not working on any of the servers.

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 7:49 AM
  • WMI is not working on any of the servers.

    You need to have this fixed ASAP

    /Peter

    Tuesday, August 22, 2017 7:53 AM
  • actually sometimes receive location shows green in admin console but it actually in the painding state.

    In that case it will be disabled and administrator will think that its enabled by the script and then no messages will be picked by biztalk.

    :-(

    As its client server and I am quite new so little bit afraid to do any repair(will it affect the BT installation?)


    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 7:53 AM
  • WMI is not working on any of the servers.

    You need to have this fixed ASAP

    /Peter

    How to fix this, as it says not broken after running winmgmt /verifyrepository

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 7:57 AM
  • Will a refresh show the correct state?
    The Administration Console will only show cached data, you need to manually refresh

    /Peter

    Tuesday, August 22, 2017 7:57 AM
  • Hi Har,

    Try following script

    Function EnableReceiveLocations
    {
        $rlColl = get-wmiobject -Class MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer'
        foreach
        ($rl in $rlColl)
        {
            if($rl.IsDisabled -eq $true)
            {
                $hrResult = $rl.Enable()
            }
        }
    }
    EnableReceiveLocations
    Customize it if required


    Mandar Dharmadhikari

    Tuesday, August 22, 2017 7:59 AM
    Moderator
  • You need to start a new thread repairing WMI as it's a complex subject

    /Peter

    Tuesday, August 22, 2017 8:08 AM
  • Hi Har,

    Try following script

    Function EnableReceiveLocations
    {
        $rlColl = get-wmiobject -Class MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer'
        foreach
        ($rl in $rlColl)
        {
            if($rl.IsDisabled -eq $true)
            {
                $hrResult = $rl.Enable()
            }
        }
    }
    EnableReceiveLocations
    Customize it if required


    Mandar Dharmadhikari

    $rlColl = get-wmiobject -Class MSBTS_ReceiveLocation -namespace 'root\MicrosoftBizTalkServer'
    this itself is not working for me its resulting in empty $rlColl object :-(

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    Tuesday, August 22, 2017 8:18 AM
  • Hi Har,

    I would suggest you try a repair of the BizTalk. The script I shared is fully functional and I have tried it on my machine


    Mandar Dharmadhikari

    Tuesday, August 22, 2017 9:17 AM
    Moderator
  • Hi Har,

    Have u got solution of your query since i am also facing the same issue in my case MSBTS_SendPort class is not working and other artifact classes are working fine

    Monday, October 16, 2017 1:32 PM
  • No, it did not worked.

    but then I used ExplorerOM to fix the issue for timebeing.

    Function EnableReceiveLocations
           {
            [System.reflection.Assembly]::LoadWithPartialName("Microsoft.Biztalk.ExplorerOM")
            $bto=New-Object  Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
            $bto.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server=."
            $rpColl = $bto.ReceivePorts
            foreach($rp in $rpColl)
            {
                $rlColl = $rp.ReceiveLocations
                foreach($rl in $rlColl)
                {
                    if($rl.Enable -eq $false)
                    {
                        $rl.Enable = $true
                        Write-Host('Receive Location'+ $rl.Name + ' enabled')
                    }
                    else
                    {
                        Write-Host('Receive Location'+ $rl.Name + ' already enabled')
                        
                    }
                }
            }
              $bto.SaveChanges() 
              $bto.Refresh()
           }
           
           
           
           EnableReceiveLocations
    If you get any workaround, please let me know. Thank you

    When you see answers and helpful posts, please click Vote As Helpful , Propose As Answer , and/or Mark As Answer

    • Marked as answer by har Monday, October 16, 2017 1:55 PM
    Monday, October 16, 2017 1:54 PM