I'm trying to run an WQL query(SELECT * FROM MSBTS_SendPort) on an BizTalk host but when I run this query in my console application on an remote primary BizTalkHost I get an COMException who says "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'."
If I run the same console application on the primary BizTalkHost then everything works.
I'm issueing an double-hop authentication issue, so therefore what I want will never work. See this link for more information. My workaround for this issue is to create an wcf-webservice on an biztalk host and let the wcf service handle the WMI query.
If you want to use powershell for remote biztalk administration look at this link.
Looks you execute the query on the remote machine as a anonymous user - you have to be in the user context of a user that is authorized to read from the BizTalk Management database.
You could start with trying to run the console application on the remote machine using "run as" and enter the credentials that you probably login as on the BizTalk machine.
If that works you should start looking to impersonation a different user in you code.