Configure Azure Log Analytics agent to OMS log analytics gateway with powershell

Bombbe 1,626 Reputation points
2020-11-12T13:56:35.07+00:00

Hi,
as title says is it possible to Configure Azure Log Analytics agent(on-prem) to log analytics gateway with Powershell. I know what is possible to do with netsh winhttp set proxy <proxy>:<port> but then I think all traffic will got to proxy which we don't want. Then it can also be done from the Control Panel but doing that to 10 or even 100 servers would take for ever.
39421-oms.png

So doing it with Powerhsell or CMD would be best option for us because then it is also can be automated / or scripted.

I found and tried this but I did not get it working, getting error "Cannot find an overload for "SetProxyInfo" and the argument count: "1"" In our environment we don't need to use credentials or password. ip or name and port is enough. Does any have have tips or tricks?

param($ProxyDomainName="http://proxy.contoso.com:80", $cred=(Get-Credential))  
  
# First we get the Health Service configuration object.  We need to determine if we  
# have the right update rollup with the API we need.  If not, no need to run the rest of the script.  
$healthServiceSettings = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
  
$proxyMethod = $healthServiceSettings | Get-Member -Name 'SetProxyInfo'  
  
if (!$proxyMethod)  
{  
    Write-Output 'Health Service proxy API not present, will not update settings.'  
    return  
}  
  
Write-Output "Clearing proxy settings."  
$healthServiceSettings.SetProxyInfo('', '', '')  
  
$ProxyUserName = $cred.username  
  
Write-Output "Setting proxy to $ProxyDomainName with proxy username $ProxyUserName."  
$healthServiceSettings.SetProxyInfo($ProxyDomainName, $ProxyUserName, $cred.GetNetworkCredential().password)  
Azure Analysis Services
Azure Analysis Services
An Azure service that provides an enterprise-grade analytics engine.
454 questions
0 comments No comments
{count} votes

Accepted answer
  1. Roderick Bant 2,051 Reputation points
    2020-11-12T17:09:46.307+00:00

    No really clear documentation on this. You could try using '' or $null as arguments for the SetProxyInfo method on line 21.

    $healthServiceSettings.SetProxyInfo($ProxyDomainName, '', '')
    

    or

    $healthServiceSettings.SetProxyInfo($ProxyDomainName, $null, $null)
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.