Logging icon indicating copy to clipboard operation
Logging copied to clipboard

MS Teams Target: Proxy Support

Open kilale opened this issue 4 years ago • 1 comments

Hi, is there a chance to get support for a proxy setting within the MS Teams target? Maybe this is also relevant for other target plugins. We could add this as a setting for the $Configuration variable. Optional parameter, if not set, it is not used.

Thanks for the support so far!

kilale avatar Mar 29 '21 17:03 kilale

An example:

Configuration = @{
[...]
      Proxy   = @{Required = $false; Type = [string]; Default = ""}
      ProxyCredential   = @{Required = $false; Type = [pscredential]; Default = $null}
}

[...]
 
if (($Configuration.Proxy -as [System.URI]).AbsoluteURI -ne $null) {
      # Invoking with proxy
       if ($null -ne $Configuration.ProxyCredential) {
             # With authentication 
             Invoke-RestMethod -Method POST -Uri $Configuration.WebHook -Body $Payload -ContentType 'application/json; charset=UTF-8' -Proxy $Configuration.Proxy -ProxyCredential $Configuration.ProxyCredential | Out-Null
       }else{
             # Without authentication
             Invoke-RestMethod -Method POST -Uri $Configuration.WebHook -Body $Payload -ContentType 'application/json; charset=UTF-8' -Proxy $Configuration.Proxy | Out-Null
      }
}else{
      # Invoking without proxy
       Invoke-RestMethod -Method POST -Uri $Configuration.WebHook -Body $Payload -ContentType 'application/json; charset=UTF-8' | Out-Null
}

kilale avatar Mar 30 '21 15:03 kilale