Public/SEPPMailAPI-Disclaimer.ps1

<# #TODO: Delete after Find-SMASisclaimer Works
.SYNOPSIS
List your disclaimers.
.DESCRIPTION
This CmdLet lets you read the detailed properties of your disclaimers.
.EXAMPLE
    PS C:\> Find-SMADisclaimer
    Emits all disclaimers and their details - may take some time
.EXAMPLE
    PS C:\> Find-SMADisclaimer -List
    Emits all disclaimer names
#>

<#
function Find-SMADisclaimer
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory = $false,
            HelpMessage = 'Show list with disclaimer names only'
            )]
        [switch]$list,
 
        [Parameter(
             Mandatory = $false,
             HelpMessage = "Limit output to a specific disclaimer"
         )]
        [string] $name,
 
        [Parameter(
             Mandatory = $false,
             HelpMessage = "Also return base64 encoded data of inlines and attachments"
         )]
        [switch] $withData,
 
        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,
 
        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,
 
        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,
 
        [Parameter(
             Mandatory=$false
         )]
        [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,
 
        [Parameter(
             Mandatory=$false
         )]
        [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )
 
 
    if (!(verifyVars -VarList $Script:requiredVarList))
    {
        Throw($missingVarsMessage);
    }; # end if
 
    try {
        Write-Verbose "Creating URL Path"
        $uriPath = 'mailsystem/disclaimer'
 
        Write-verbose "Build Parameter hashtable"
        $boundParam = @{}
 
        if($list)
        {$boundParam["list"] = $true}
        if($name)
        {$boundParam["name"] = $name}
        if($customer)
        {$boundParam["withData"] = $true}
 
        Write-Verbose "Build QueryString"
        $smaParams=@{
            Host=$SMAHost;
            Port=$SMAPort;
            Version=$SMAVersion;
        }; # end smaParams
        $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;
 
        Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
        $invokeParam = @{
            Uri = $uri
            Method = 'GET'
            Cred = $SMACred
            SkipCertCheck = $SMASkipCertCheck
        }
 
        Write-Verbose "Call Invoke-SMARestMethod $uri"
        $tmp = Invoke-SMARestMethod @invokeParam
 
        Write-Verbose 'Filter data and return as PSObject'
 
        if (!$list) {
            $tmp = $tmp.Psobject.properties.value
        }
 
        Write-Verbose 'Converting Umlauts from ISO-8859-1 and DateTime correctly'
        $ret = foreach ($c in $tmp) {ConvertFrom-SMAPIFormat -inputobject $c}
 
        if ($ret) {
            return $ret
        }
        else {
            Write-Information 'Nothing to return'
        }
    }
    catch {
        Write-Error "An error occured, see $error"
    }
}
#>


<#
.SYNOPSIS
    List SEPPmail disclaimers.
.DESCRIPTION
    Reads the configured disclaimers from the SEPPmail appliance via a GET
    request to the 'mailsystem/disclaimer' API endpoint. The 'list' query
    parameter is set internally, so the CmdLet returns the disclaimer names.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the list of configured disclaimers.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Get-SMADisclaimer
.LINK
    New-SMADisclaimer
.LINK
    Set-SMADisclaimer
.LINK
    Remove-SMADisclaimer
.EXAMPLE
    PS C:\> Find-SMADisclaimer
    List all configured disclaimers.
#>

function Find-SMADisclaimer
{
    [CmdletBinding(
        SupportsShouldProcess = $true
    )]
    param (
        #region API params
        #endregion API params
        
        #region Config parameters block
        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(Mandatory=$false)]
        [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,
        
        [Parameter(Mandatory=$false)]
        [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
        #endregion
    )

    begin {
        Write-verbose "Verifying required variables from SMA Config"
        if (! (verifyVars -VarList $Script:requiredVarList)) {Throw($missingVarsMessage)} # end if

        Write-verbose "Rest methdod is $restMethod"
        $RestMethod = 'GET'

        Write-Verbose "Creating URL base path"
        $uriPath = "{0}/{1}" -f 'mailsystem', 'disclaimer'

        Write-Verbose "Adding SMA Params"
        $smaParams=@{
            Host    = $SMAHost
            Port    = $SMAPort
            Version = $SMAVersion
        }
    }
    process {   
        Write-Verbose "Getting parameter arrays for Body, Path and Query from $($myInvocation.Mycommand.Parameters.Values)"
        $paramArrays = Get-SMAParameterArray -ParentPSBoundParameters $PSBoundParameters -ParentInvocation $MyInvocation.MyCommand.Parameters.Values
        Write-Debug "ParamArrays: $($paramArrays | Out-String)"

        Write-verbose "Initializing REST-Data structures"
        [string]$uri                = $null
        [hashtable]$bodyHt          = @{}
        [hashtable]$queryParamHt    = @{}

        Write-verbose "Adding optional path to basepath based on $($paramArrays.Path) parameters"
        if ($paramArrays.Path.Count -gt 0) {
            Foreach ($pathParam in $paramArrays.Path) {
                $uriPath = "{0}/{1}" -f $uriPath, $PSBoundParameters[$pathParam]
            }
        }
        Write-Debug "Final uri path is: $uriPath"

        Write-verbose "Building body HashTable based on $($paramArrays.Body) parameters"
        if ($paramArrays.Body.Count -gt 0) {
            Foreach ($bodyParam in $paramArrays.Body) {
                $bodyHt[$bodyParam] = $PSBoundParameters[$bodyParam]
            }
        }
        if ($paramArrays.password.Count -gt 0) {
            Foreach ($passwordParam in $paramArrays.password) {
                $secureString = $PSBoundParameters[$passwordParam]
                $plainText = ConvertFrom-SecureString $secureString -AsPlainText
                $bodyHt[$passwordParam] = $plainText
            }
        }
        $body = $bodyHt | ConvertTo-Json
        Write-Debug "Body JSON: $body"

        #Hardcoding -LIST Query Param


        Write-verbose "Building query string based on $($paramArrays.Query) parameters"
        if ($paramArrays.Query.Count -gt 0) {
            Foreach ($queryArrayParam in $paramArrays.Query) {
                $queryParamHt[$queryArrayParam] = $PSBoundParameters[$queryArrayParam]
            }
        }
        Write-Debug "QueryParams: $($queryParamHt | Out-String)"

        $queryParamHt['list'] = $true
        Write-Verbose "Constructing full URI based on parameters"
        if ($queryParamHt) {
            $uri = New-SMAQueryString -uriPath $uriPath -qParam $queryParamHt @smaParams
        }
        else {
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams
        }
        Write-Debug "Final URI: $uri"

        Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
        $invokeParam = @{
                      Uri = $uri 
                   Method = $RestMethod
                     Cred = $SMACred
                     body = $body
            SkipCertCheck = $SMASkipCertCheck
        }
        Write-Debug "InvokeParam: $($invokeParam | Out-String)"

        # Prepare WhatIf message based on invokeParam
        $whatIfTarget = $invokeParam.Uri
        $whatIfAction = "$($invokeParam.Method) request"
        if ($invokeParam.body) {
            $whatIfAction += " with body: $($invokeParam.body)"
        }

        if ($PSCmdlet.ShouldProcess($whatIfTarget, $whatIfAction)) {
            Write-Verbose "Call Invoke-SMARestMethod $uri" 
            $RestResult = Invoke-SMARestMethod @invokeParam
            # Return object
            if ($RestResult) {
                $returnData = Format-SMARestResult $RestResult -object #TODO: object, StringPos3, StringPos2to4, StringPos2to6, StringPos0to3,StringPos0to9, objectArray, nattiveJson
                return $returnData
            }
            else {
                Write-Information 'Nothing to return'
            }
        }
        else {
            Write-Verbose "WhatIf: Operation skipped by user"
        }
    }
    end {
    }
}

<#
.SYNOPSIS
    Get the details of a specific SEPPmail disclaimer.
.DESCRIPTION
    Reads the detailed properties of a single disclaimer from the SEPPmail
    appliance via a GET request to the 'mailsystem/disclaimer' API endpoint,
    passing the disclaimer name as a query parameter.
.PARAMETER name
    Name of the disclaimer to query (mandatory). Accepts pipeline input by value,
    so multiple disclaimer names can be piped in.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the detailed properties of the requested disclaimer.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
.LINK
    Find-SMADisclaimer
.LINK
    New-SMADisclaimer
.LINK
    Set-SMADisclaimer
.LINK
    Remove-SMADisclaimer
.EXAMPLE
    PS C:\> Get-SMADisclaimer -name 'Example'
    Get the details of the 'Example' disclaimer.
.EXAMPLE
    PS C:\> 'example1','example2' | Get-SMADisclaimer
    Use the pipeline to query multiple disclaimers.
#>

function Get-SMADisclaimer
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipeline               = $true,
            HelpMessage                     = 'Diclaimer name'
            )]
        [string]$name,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
             Mandatory=$false
         )]
        [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

        [Parameter(
             Mandatory=$false
         )]
        [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
    }
    process {
        try {
            Write-Verbose "Creating URL Path"
            $uriPath = "{0}" -f 'mailsystem/disclaimer'

            Write-Verbose "Build QueryString"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams -qParam @{name = $name}

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri
                Method      = 'GET'
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }
            Write-Verbose "Call Invoke-SMARestMethod $uri"
            $tmp = Invoke-SMARestMethod @invokeParam

            Write-Verbose 'Filter data and return as PSObject'
            $ret = $tmp.Psobject.properties.value

            Write-Verbose 'Converting Umlauts from ISO-8859-1'
            $ret = ConvertFrom-SMAPIFormat -inputObject $ret

            # CustomerObject
            if ($ret) {
                return $ret
            }
            else {
                Write-Information 'Nothing to return'
            }
        }
        catch {
            Write-Error "An error occured, see $error"
        }
    }
    end {
    }
}

<#
.SYNOPSIS
    Create a new SEPPmail disclaimer.
.DESCRIPTION
    Creates a new disclaimer on the SEPPmail appliance via a POST request to the
    'mailsystem/disclaimer' API endpoint. The disclaimer name and the part flags
    are always sent; HTML/text bodies, inlines and attachments are added when
    supplied.
.PARAMETER name
    Name of the disclaimer to create (mandatory). Accepts pipeline input by value
    and by property name.
.PARAMETER addHtmlPart
    Switch. When set, an HTML part is added to the disclaimer.
.PARAMETER addTextPart
    Switch. When set, a plain text part is added to the disclaimer.
.PARAMETER forceUtf8
    Switch. When set, the disclaimer content is forced to UTF-8 encoding.
.PARAMETER addEmptyParts
    Switch. When set, empty parts are added to the disclaimer.
.PARAMETER html
    The HTML body of the disclaimer.
.PARAMETER plainText
    The plain text body of the disclaimer (sent as the 'text' property).
.PARAMETER inlines
    An array of hashtables describing inline content, e.g.
    @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}.
.PARAMETER attachments
    An array of hashtables describing attachments, e.g.
    @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the API response message for the created disclaimer.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Find-SMADisclaimer
.LINK
    Get-SMADisclaimer
.LINK
    Set-SMADisclaimer
.LINK
    Remove-SMADisclaimer
.EXAMPLE
    PS C:\> New-SMADisclaimer -name 'Example' -addHtmlPart -html '<p>Confidential</p>'
    Create a new disclaimer with an HTML part.
.EXAMPLE
    PS C:\> New-SMADisclaimer -name 'Example' -addTextPart -plainText 'Confidential' -forceUtf8
    Create a new disclaimer with a UTF-8 encoded plain text part.
#>

function New-SMADisclaimer
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
             Mandatory                       = $true,
             ValueFromPipelineByPropertyName = $true,
             ValueFromPipeline               = $true,
             HelpMessage                     = 'The disclaimer name'
         )]
        [string]$name,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addHtmlPart,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addTextPart,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$forceUtf8,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addEmptyParts,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$html,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [string] $plainText,

        [Parameter(
            Mandatory = $false,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage = 'An array of hashtables like so: @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}'
        )]
        [hashtable[]] $inlines,

        [Parameter(
             Mandatory                       = $false,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage = 'An array of hashtables like so: @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo" }'

            )]
        [hashtable[]]$attachments,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
            Mandatory=$false
            )]
            [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}" -f 'mailsystem/disclaimer'

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
        }
        catch {
            Write-Error "Error $error,CategoryInfo occured"
        }
    }
    process {
        try {
            Write-Verbose 'Crafting mandatory $body JSON'
            $bodyht = @{
                disclaimerName = $name
                addHTMLPart = $addHtmlPart.ToBool()
                addTextPart = $addTextPart.ToBool()
                forceUTF8 = $forceUtf8.ToBool()
                addEmptyParts = $addEmptyParts.ToBool()
            }

            Write-Verbose 'Adding Optional values to $body JSON'

            if($html)
            {$bodyht.html = $html}
            if($plainText)
            {$bodyht.text = $plainText}

            if($inlines)
            {$bodyht.inlines = $inlines}
            if($attachments)
            {$bodyht.attachments = $attachments}

            $body = $bodyht|ConvertTo-JSON

            $invokeParam = @{
                Uri         = $uri
                Method      = 'POST'
                body        = $body
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }

            if ($PSCmdLet.ShouldProcess($($bodyht.Name),"Create disclaimer")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $tmp = Invoke-SMARestMethod @invokeParam

                Write-Verbose 'Returning name of disclaimer'
                $tmp.message
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

<#
.SYNOPSIS
    Modify an existing SEPPmail disclaimer.
.DESCRIPTION
    Updates an existing disclaimer on the SEPPmail appliance via a PUT request to
    the 'mailsystem/disclaimer/{name}' API endpoint. The disclaimer name and the
    part flags are always sent; HTML/text bodies, inlines and attachments are
    updated when supplied.
.PARAMETER name
    Name of the disclaimer to modify (mandatory). Accepts pipeline input by value
    and by property name.
.PARAMETER addHtmlPart
    Switch. When set, an HTML part is added to the disclaimer.
.PARAMETER addTextPart
    Switch. When set, a plain text part is added to the disclaimer.
.PARAMETER forceUtf8
    Switch. When set, the disclaimer content is forced to UTF-8 encoding.
.PARAMETER addEmptyParts
    Switch. When set, empty parts are added to the disclaimer.
.PARAMETER html
    The HTML body of the disclaimer.
.PARAMETER plainText
    The plain text body of the disclaimer (sent as the 'text' property).
.PARAMETER inlines
    An array of hashtables describing inline content, e.g.
    @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}.
.PARAMETER attachments
    An array of hashtables describing attachments, e.g.
    @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the API response message for the modified disclaimer.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Find-SMADisclaimer
.LINK
    Get-SMADisclaimer
.LINK
    New-SMADisclaimer
.LINK
    Remove-SMADisclaimer
.EXAMPLE
    PS C:\> Set-SMADisclaimer -name 'Example' -addHtmlPart -html '<p>Updated</p>'
    Update the HTML part of the 'Example' disclaimer.
#>

function Set-SMADisclaimer
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
             Mandatory                       = $true,
             ValueFromPipelineByPropertyName = $true,
             ValueFromPipeline               = $true,
             HelpMessage                     = 'The disclaimer name'
         )]
        [string]$name,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addHtmlPart,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addTextPart,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$forceUtf8,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [switch]$addEmptyParts,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$html,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true
            )]
        [string] $plainText,

        [Parameter(
            Mandatory = $false,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage = 'An array of hashtables like so: @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo"}'
        )]
        [hashtable[]] $inlines,

        [Parameter(
             Mandatory                       = $false,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage = 'An array of hashtables like so: @{fileName = "logo.gif"; fileData = "base64"; contentType = "image/gif"; contentID = "logo" }'

            )]
        [hashtable[]]$attachments,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
            Mandatory=$false
            )]
            [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}" -f 'mailsystem/disclaimer', $name

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
        }
        catch {
            Write-Error "Error $error,CategoryInfo occured"
        }
    }
    process {
        try {
            Write-Verbose 'Crafting mandatory $body JSON'
            $bodyht = @{
                disclaimerName = $name
                addHTMLPart = $addHtmlPart.ToBool()
                addTextPart = $addTextPart.ToBool()
                forceUTF8 = $forceUtf8.ToBool()
                addEmptyParts = $addEmptyParts.ToBool()
            }

            Write-Verbose 'Adding Optional values to $body JSON'

            if($html)
            {$bodyht.html = $html}
            if($plainText)
            {$bodyht.text = $plainText}

            if($inlines)
            {$bodyht.inlines = $inlines}
            if($attachments)
            {$bodyht.attachments = $attachments}

            $body = $bodyht|ConvertTo-JSON

            $invokeParam = @{
                Uri         = $uri
                Method      = 'PUT'
                body        = $body
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }

            if ($PSCmdLet.ShouldProcess($($bodyht.Name),"Modfy disclaimer")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $tmp = Invoke-SMARestMethod @invokeParam

                Write-Verbose 'Returning name of disclaimer'
                $tmp.message
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

<#
.SYNOPSIS
    Remove a SEPPmail disclaimer.
.DESCRIPTION
    Deletes a disclaimer from the SEPPmail appliance via a DELETE request to the
    'mailsystem/disclaimer/{name}' API endpoint.
.PARAMETER name
    Name of the disclaimer to delete (mandatory). Accepts pipeline input by value
    and by property name and may be supplied positionally.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the API response details of the delete operation.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Find-SMADisclaimer
.LINK
    Get-SMADisclaimer
.LINK
    New-SMADisclaimer
.LINK
    Set-SMADisclaimer
.EXAMPLE
    PS C:\> Remove-SMADisclaimer -name 'example'
    Delete a disclaimer.
.EXAMPLE
    PS C:\> 'example1','example2' | Remove-SMADisclaimer
    Delete multiple disclaimers by using the pipeline.
.EXAMPLE
    PS C:\> Remove-SMADisclaimer -name 'example' -WhatIf
    Simulate the disclaimer deletion.
#>

function Remove-SMADisclaimer
{
    [CmdletBinding(DefaultParameterSetName = 'Default',SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            ParameterSetName                = 'Default',
            Position                        = 0,
            HelpMessage                     = 'The disclaimer you want to delete'
            )]
        [string]$name,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
            Mandatory=$false
            )]
            [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck

    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
    }
    process {
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}" -f 'mailsystem/disclaimer', $name

            Write-Verbose "Building param query"
            $boundParam = $pscmdlet.MyInvocation.BoundParameters
            $boundParam.Remove('name')|out-null
            $boundParam.Remove('whatif')|out-null

            Write-Verbose "Building full request uri"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri
                Method      = 'DELETE'
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }
            if ($PSCmdLet.ShouldProcess($name, "Remove disclaimer")){
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                # Wait-Debugger
                $tmp = Invoke-SMARestMethod @invokeParam
                Write-Verbose 'Returning Delete details'
                $tmp.psobject.Properties.Value
            }
        }
        catch {
            Write-Error "An error occured, see $error"
        }
    }
    end {

    }

}


<#
.SYNOPSIS
    Get the includes of a SEPPmail disclaimer.
.DESCRIPTION
    Reads the inline or attachment includes of a disclaimer from the SEPPmail
    appliance via a GET request to the 'mailsystem/disclaimer/{disclaimer}/{type}'
    API endpoint.
.PARAMETER list
    Switch. When set, only the include names are returned instead of their full
    details.
.PARAMETER disclaimer
    Name of the disclaimer whose includes are queried (mandatory).
.PARAMETER withData
    Switch. When set, the base64 encoded data of inlines and attachments is also
    returned.
.PARAMETER type
    Type of the include (mandatory). Valid values: 'inline', 'attachment'.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the includes of the requested disclaimer.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
.LINK
    New-SMADisclaimerInclude
.LINK
    Remove-SMADisclaimerInclude
.EXAMPLE
    PS C:\> Get-SMADisclaimerInclude -disclaimer 'Example' -type inline
    Get the inline includes of the 'Example' disclaimer.
.EXAMPLE
    PS C:\> Get-SMADisclaimerInclude -disclaimer 'Example' -type attachment -list
    List the attachment include names of the 'Example' disclaimer.
.EXAMPLE
    PS C:\> Get-SMADisclaimerInclude -disclaimer 'Example' -type inline -withData
    Get the inline includes including their base64 encoded data.
#>

function Get-SMADisclaimerInclude
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory                       = $false,
            HelpMessage                     = 'Show list with disclaimer include names only'
            )]
        [switch]$list,

        [Parameter(
             Mandatory = $true,
             HelpMessage = "Limit output to a specific disclaimer"
         )]
        [string] $disclaimer,

        [Parameter(
             Mandatory = $false,
             HelpMessage = "Also return base64 encoded data of inlines and attachments"
         )]
        [switch]$withData,

        [Parameter(
             Mandatory = $true,
             HelpMessage = "Type of the include (inline or attachment)"
         )]
        [ValidateSet('inline', 'attachment')]
        [string] $type,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
             Mandatory=$false
         )]
        [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

        [Parameter(
             Mandatory=$false
         )]
        [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )


    if (!(verifyVars -VarList $Script:requiredVarList))
    {
        Throw($missingVarsMessage);
    }; # end if

    try {
        Write-Verbose "Creating URL Path"
        $uriPath = 'mailsystem/disclaimer/{0}/{1}' -f $disclaimer, $type

        Write-verbose "Build Parameter hashtable"
        $boundParam = @{}

        if($list)
        {$boundParam["list"] = $true}
        if($customer)
        {$boundParam["withData"] = $true}

        Write-Verbose "Build QueryString"
        $smaParams=@{
            Host=$SMAHost;
            Port=$SMAPort;
            Version=$SMAVersion;
        }; # end smaParams
        $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;

        Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
        $invokeParam = @{
            Uri         = $uri
            Method      = 'GET'
            Cred        =  $SMACred
            SkipCertCheck = $SMASkipCertCheck
        }

        Write-Verbose "Call Invoke-SMARestMethod $uri"
        $tmp = Invoke-SMARestMethod @invokeParam

        Write-Verbose 'Filter data and return as PSObject'

        if (!$list) {
            $tmp = $tmp.Psobject.properties.value
        }

        Write-Verbose 'Converting Umlauts from ISO-8859-1 and DateTime correctly'
        $ret = foreach ($c in $tmp) {ConvertFrom-SMAPIFormat -inputobject $c}

        if ($ret) {
            return $ret
        }
        else {
            Write-Information 'Nothing to return'
        }
    }
    catch {
        Write-Error "An error occured, see $error"
    }
}



<#
.SYNOPSIS
    Create a new SEPPmail disclaimer include.
.DESCRIPTION
    Creates a new inline or attachment include for a disclaimer on the SEPPmail
    appliance via a POST request to the
    'mailsystem/disclaimer/{disclaimer}/{type}' API endpoint.
.PARAMETER disclaimer
    Name of the disclaimer the include belongs to (mandatory).
.PARAMETER type
    Type of the include (mandatory). Valid values: 'inline', 'attachment'.
.PARAMETER fileName
    File name of the include (mandatory).
.PARAMETER fileData
    Base64 encoded data of the include (mandatory).
.PARAMETER contentType
    MIME content type of the include, e.g. 'image/gif' (mandatory).
.PARAMETER contentId
    Content ID of the include (mandatory).
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the API response message for the created include.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Get-SMADisclaimerInclude
.LINK
    Remove-SMADisclaimerInclude
.EXAMPLE
    PS C:\> New-SMADisclaimerInclude -disclaimer 'Example' -type inline -fileName 'logo.gif' -fileData $b64 -contentType 'image/gif' -contentId 'logo'
    Create a new inline include for the 'Example' disclaimer.
#>

function New-SMADisclaimerInclude
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
             Mandatory                       = $true,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage                     = 'The disclaimer name'
         )]
        [string]$disclaimer,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true
            )]
        [ValidateSet('inline', 'attachment')]
        [string]$type,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$fileName,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$fileData,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$contentType,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true
            )]
        [string]$contentId,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
            Mandatory=$false
            )]
            [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck
    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}/{2}" -f 'mailsystem/disclaimer', $disclaimer, $type

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
        }
        catch {
            Write-Error "Error $error,CategoryInfo occured"
        }
    }
    process {
        try {
            Write-Verbose 'Crafting mandatory $body JSON'
            $bodyht = @{
                fileName = $fileName
                fileDate = $fileData
                contentType = $contentType
                contentID = $contentId
            }

            Write-Verbose 'Adding Optional values to $body JSON'

            $body = $bodyht|ConvertTo-JSON

            $invokeParam = @{
                Uri         = $uri
                Method      = 'POST'
                body        = $body
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }

            if ($PSCmdLet.ShouldProcess($($bodyht.Name),"Create disclaimer include")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $tmp = Invoke-SMARestMethod @invokeParam

                Write-Verbose 'Returning name of disclaimer include'
                $tmp.message
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

<#
.SYNOPSIS
    Remove a SEPPmail disclaimer include.
.DESCRIPTION
    Deletes one or more inline or attachment includes of a disclaimer on the
    SEPPmail appliance via a DELETE request to the
    'mailsystem/disclaimer/{disclaimer}/{type}' API endpoint. The include names
    are sent in the request body.
.PARAMETER name
    One or more include names to delete (mandatory). Accepts pipeline input by
    value and by property name and may be supplied positionally.
.PARAMETER disclaimer
    Name of the disclaimer the include belongs to (mandatory).
.PARAMETER type
    Type of the include (mandatory). Valid values: 'inline', 'attachment'.
.PARAMETER SMAHost
    SEPPmail API hostname. Defaults to the configured value.
.PARAMETER SMAPort
    SEPPmail API port. Defaults to the configured value.
.PARAMETER SMAVersion
    SEPPmail API version. Defaults to the configured value.
.PARAMETER SMACred
    API credentials (PSCredential). Defaults to the configured value.
.PARAMETER SMASkipCertCheck
    Skip SSL certificate validation. Use only in test environments.
.OUTPUTS
    System.Management.Automation.PSCustomObject
        Returns the API response details of the delete operation.
.NOTES
    - Requires an active SEPPmail API session (New-SMAConfiguration).
    - Supports -WhatIf and -Confirm.
.LINK
    Get-SMADisclaimerInclude
.LINK
    New-SMADisclaimerInclude
.EXAMPLE
    PS C:\> Remove-SMADisclaimerInclude -name 'logo' -type inline -disclaimer 'Example'
    Delete the 'logo' inline include from the 'Example' disclaimer.
#>

function Remove-SMADisclaimerInclude
{
    [CmdletBinding(DefaultParameterSetName = 'Default',SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            ParameterSetName                = 'Default',
            Position                        = 0,
            HelpMessage                     = 'Name of the includes you want to delete'
            )]
        [string[]]$name,

        [Parameter(
             Mandatory = $true,
             ValueFromPipelineByPropertyName = $true,
             HelpMessage = 'The disclaimer name'
         )]
        [string]$disclaimer,

        [Parameter(
             Mandatory = $true,
             ValueFromPipelineByPropertyName = $true
         )]
        [ValidateSet('inline', 'attachment')]
        [string]$type,

        [Parameter(Mandatory = $false)]
        [String]$SMAHost = $Script:activeCfg.SMAHost,

        [Parameter(Mandatory = $false)]
        [int]$SMAPort = $Script:activeCfg.SMAPort,

        [Parameter(Mandatory = $false)]
        [String]$SMAVersion = $Script:activeCfg.SMAPIVersion,

        [Parameter(
            Mandatory=$false
            )]
            [System.Management.Automation.PSCredential]$SMACred=$Script:activeCfg.SMACred,

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SMASkipCertCheck=$Script:activeCfg.SMAskipCertCheck

    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
    }
    process {
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}/{2}" -f 'mailsystem/disclaimer', $disclaimer, $type

            Write-Verbose "Building param query"
            $boundParam = $pscmdlet.MyInvocation.BoundParameters
            $boundParam.Remove('name')|out-null
            $boundParam.Remove('whatif')|out-null

            Write-Verbose "Building full request uri"
            $smaParams=@{
                Host=$SMAHost;
                Port=$SMAPort;
                Version=$SMAVersion;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;

            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri
                Method      = 'DELETE'
                Cred        =  $SMACred
                SkipCertCheck = $SMASkipCertCheck
            }
            if ($PSCmdLet.ShouldProcess($name, "Remove disclaimer")){
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                # Wait-Debugger
                $tmp = Invoke-SMARestMethod @invokeParam -Body $name
                Write-Verbose 'Returning Delete details'
                $tmp.psobject.Properties.Value
            }
        }
        catch {
            Write-Error "An error occured, see $error"
        }
    }
    end {

    }

}

# SIG # Begin signature block
# MIIVyAYJKoZIhvcNAQcCoIIVuTCCFbUCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCeFkL7//IwWI2z
# kmq81WTS15gGa71ux6PqGriPfiR97KCCEgQwggVvMIIEV6ADAgECAhBI/JO0YFWU
# jTanyYqJ1pQWMA0GCSqGSIb3DQEBDAUAMHsxCzAJBgNVBAYTAkdCMRswGQYDVQQI
# DBJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoM
# EUNvbW9kbyBDQSBMaW1pdGVkMSEwHwYDVQQDDBhBQUEgQ2VydGlmaWNhdGUgU2Vy
# dmljZXMwHhcNMjEwNTI1MDAwMDAwWhcNMjgxMjMxMjM1OTU5WjBWMQswCQYDVQQG
# EwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMS0wKwYDVQQDEyRTZWN0aWdv
# IFB1YmxpYyBDb2RlIF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