Logging
Logging copied to clipboard
MS Teams Target: Proxy Support
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!
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
}