Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS Teams Target: Proxy Support #118

Open
kilale opened this issue Mar 29, 2021 · 1 comment
Open

MS Teams Target: Proxy Support #118

kilale opened this issue Mar 29, 2021 · 1 comment

Comments

@kilale
Copy link

kilale commented Mar 29, 2021

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
Copy link
Author

kilale commented Mar 30, 2021

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant