Public/Spamfilter/New-SpamfilterDomain.ps1
function New-SpamfilterDomain { Param( [Parameter(Mandatory)] [string]$DomainName, [Parameter(Mandatory)] [string]$Destination ) process { try { $Credential = Get-SpamFilterCredential } catch { throw "Failed to retreive Spamfilter credential: $_" } try { $DomainName = [System.Web.HttpUtility]::UrlEncode($DomainName) $Destination = [System.Web.HttpUtility]::UrlEncode($Destination) $CompleteURI = "$($SpamfilterAPIBaseURL)/domain/add/domain/$($DomainName)/destinations/[" + '"' + $Destination + '"]' $Response = (Invoke-WebRequest -Credential $Credential -Uri $CompleteURI).Content } catch { throw "Failed to add domain to spamfilter: $_" } $Response } } |