Public/SEPPmailAPI-Customer.ps1

<#
.SYNOPSIS
    Find a locally existing users and details
.DESCRIPTION
    This CmdLet lets you read the detailed properties of multiple users.
.EXAMPLE
    PS C:\> Find-SMACustomer
    Emits all customers and their details - may take some time
.EXAMPLE
    PS C:\> Find-SMAUser -List
    Emits all customers names
#>

function Find-SMACustomer
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory                       = $false,
            HelpMessage                     = 'Show list with e-mail address only'
            )]
        [switch]$list,

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

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

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

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

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

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

    try {
        Write-Verbose "Creating URL Path"
        $uriPath = 'customer'

        Write-verbose "Build Parameter hashtable"
        $boundParam = @{list=$list}
        
        Write-Verbose "Build QueryString"
        $smaParams=@{
            Host=$Host;
            Port=$Port;
            Version=$Version;
        }; # end smaParams
        $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;

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

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

        Write-Verbose 'Filter data and return as PSObject'

        if ($list) {
            $Findcustomer = $customerRaw
        }
        else {
            $FindCustomer = $customerRaw.Psobject.properties.value
        }

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

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

<#
.SYNOPSIS
    Get a locally existing customes properties
.DESCRIPTION
    This CmdLet lets you read the detailed properties of an existing customer.
.EXAMPLE
    PS C:\> Get-SMACustomer -name 'Fabrikam'
    Get information about a SEPPmail customer.
    NOTE!: Customer names are case-sensitive
.EXAMPLE
    PS C:\> 'Contoso','Fabrikam'|Get-SMACustomer
    Use the pipeline to query multiple customers
    NOTE!: Customer names are case-sensitive
#>

function Get-SMACustomer
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipeline               = $true,
            HelpMessage                     = 'Customer name (Case sensitive!)'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

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

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

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

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

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

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
    {
        Throw($missingVarsMessage);
    }; # end if
    }
    process {
        try {
            Write-Verbose "Creating URL Path"
            $uriPath = "{0}/{1}" -f 'customer', $name
    
            Write-Verbose "Build QueryString"
            $smaParams=@{
                Host=$Host;
                Port=$Port;
                Version=$Version;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
    
            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri 
                Method      = 'GET'
                Cred        =  $cred
                SkipCertCheck = $SkipCertCheck
            }
            Write-Verbose "Call Invoke-SMARestMethod $uri" 
            $customerRaw = Invoke-SMARestMethod @invokeParam
    
            Write-Verbose 'Filter data and return as PSObject'
            $GetCustomer = $customerRaw.Psobject.properties.value
    
            Write-Verbose 'Converting Umlauts from ISO-8859-1'
            $customer = ConvertFrom-SMAPIFormat -inputObject $getCustomer
    
            # CustomerObject
            if ($customer) {
                return $customer
            }
            else {
                Write-Information 'Nothing to return'
            }
        }
        catch {
            Write-Error "An error occured, see $error"
        }
    }
    end {
    }
}

<#
.SYNOPSIS
    Create a new SEPPmail Customer
.DESCRIPTION
    This CmdLet lets you create a new customer. You need at minimum the customers name.
.EXAMPLE
    PS C:\> New-SMACustomer -Name 'Fabrikam'
    Create the customer 'Fabrikam' with default values.
.EXAMPLE
    PS C:\> New-SMACustomer -Name 'Fabrikam' -adminEmail admin@fabrikam.com
    Create the customer 'Fabrikam' with default values.
.EXAMPLE
    PS C:\> New-SMACustomer -Name 'Fabrikam' -admins @('admin@fabrikam.com','admin2@fabrikam.com')
    Create a new customer and set 2 admins by defining their E-Mail adresses
.EXAMPLE
    PS C:\> $customerInfo = @{
        Name = 'Contoso'
        adminEmail = 'admin@contoso.com'
        admins = @('admin@contoso.com','admin2@contoso.com')
        backupPassword = 'someReallydifficultPassword'
        comment = 'Contoso is one of our most important clients'
        defaultGINADomain = 'ContosoMain'
        deleteOldMessagesGracePeriod = 30
        deleteUnregistered = 60
        description = 'Contoso Holding AG'
        mailRoutes = @()
        maximumEncryptionLicenses = 5
        maximumLFTLicenses = 3
        sendBackupToAdmin = $true
    }
    PS C:\> New-SMACustomer @customerInfo
    Example of all parameters possible to create a customer using PowerShell parameter splatting
#>

function New-SMACustomer
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            HelpMessage                     = 'The customers display name'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customers admin E-Mail address'
            )]
        [string]$adminEmail,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'The customers administrators uid´s as array'
            )]
        [string[]]$admins,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Backup password'
            )]
        [secureString]$backupPassword,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Some additional text'
            )]
        [string]$comment,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'GINA domain to use of none is selected'
            )]
        [string]$defaultGINADomain,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Grace period (in days) after which old GINA message metadata are automatically removed. Mails can still be decrypted by recipient if metadata is missing. (set to 0 to disable)'
            )]
        [Alias('delMessGrace')]
        [int]$deleteOldMessagesGracePeriod = 0,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Grace period (in days) after which unregistered GINA accounts are automatically removed (set to 0 to disable)'
            )]
        [Alias('delUnreg')]
        [int]$deleteUnregistered = 0,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customers more detailed description'
            )]
        [string]$description,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = '?????????????????'
            )]
        [string[]]$mailRoutes,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'How many licenses may users of this customers consume for encryption ?'
            )]
        [int]$maximumEncryptionLicenses,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'How many licenses may users of this customers consume for elarge file transfer ?'
            )]
        [int]$maximumLFTLicenses,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Automatically send backup to Customer Admin E-mail'
            )]
        [bool]$sendBackupToAdmin,

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

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

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

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

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

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}" -f 'customer'
        
            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $smaParams=@{
                Host=$Host;
                Port=$Port;
                Version=$Version;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
        }
        catch {
            Write-Error "Error $error,CategoryInfo occured"
        }
    }
    process {
        try {
            Write-Verbose 'Crafting mandatory $body JSON'
            $bodyht = @{
                name = $name
            }
            Write-Verbose 'Adding Optional values to $body JSON'
            if ($adminEmail) {$bodyht.adminEmail = $adminEmail}
            if ($admins) {$bodyht.admins = $admins}
            if ($backupPassword) {$bodyht.backupPassword = (ConvertFrom-SMASecureString -securePassword $backupPassword)}
            if ($comment) {$bodyht.comment = $comment}
            if ($defaultGINADomain) {$bodyht.defaultGINADomain = $defaultGINADomain}
            if ($deleteOldMessagesGracePeriod) {$bodyht.deleteOldMessagesGracePeriod = $deleteOldMessagesGracePeriod}
            if ($deleteUnregistered) {$bodyht.deleteUnregistered = $deleteUnregistered}
            if ($description) {$bodyht.description = $description}
            if ($mailRoutes) {$bodyht.mailRoutes = $mailRoutes}
            if ($maximumEncryptionLicenses) {$bodyht.maximumEncryptionLicenses = $maximumEncryptionLicenses}
            if ($maximumLFTLicenses) {$bodyht.maximumLFTLicenses = $maximumLFTLicenses}
            if ($sendBackupToAdmin) {$bodyht.sendBackupToAdmin = $sendBackupToAdmin}
    
            $body = $bodyht|ConvertTo-JSON
    
            $invokeParam = @{
                Uri         = $uri 
                Method      = 'POST'
                body        = $body
                Cred        =  $cred
                SkipCertCheck = $SkipCertCheck
            }

            if ($PSCmdLet.ShouldProcess($($bodyht.Name),"Create customer")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $customerRaw = Invoke-SMARestMethod @invokeParam
        
                Write-Verbose 'Returning name of customer'
                $customerRaw.message
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

<#
.SYNOPSIS
    Modyfies a SEPPmail customer
.DESCRIPTION
    This CmdLet lets you modity an existing customer. You need the customer name for identification.
.EXAMPLE
    PS C:\> Set-SMAcustomer -name 'Contoso' -description 'Contoso AG London'
    Change the description of Contoso.
.EXAMPLE
    To change multiple values of a customer at one, we recomend using paraeter splatting. Create a hashtable, like below and
    PS C:\> $customerInfo = @{
        adminEmail = 'admin@contoso.com'
        admins = @('admin@contoso.com','admin2@contoso.com')
        backupPassword = 'someReallydifficultPassword'
        comment = 'Contoso is one of our most important clients'
        defaultGINADomain = 'ContosoMain'
        deleteOldMessagesGracePeriod = 30
        deleteUnregistered = 60
        description = 'Contoso Holding AG'
        mailRoutes = @()
        maximumEncryptionLicenses = 10
        maximumLFTLicenses = 5
        sendBackupToAdmin = $true
    }
    PS C:\> Set-SMAcustomer -name 'Contoso' @customerInfo
    Example of all parameters possible to change a customer.
#>

function Set-SMACustomer
{
    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'The customers display name'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customers admin E-Mail address(es)'
            )]
        [string]$adminEmail,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'The customers administrators uid´s as array'
            )]
        [string[]]$admins,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Backup password'
            )]
        [secureString]$backupPassword,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Some additional text'
            )]
        [string]$comment,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'GINA domain to use of none is selected'
            )]
        [string]$defaultGINADomain,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Grace period (in days) after which old GINA message metadata are automatically removed. Mails can still be decrypted by recipient if metadata is missing. (set to 0 to disable)'
            )]
        [Alias('delMessGrace')]
        [int]$deleteOldMessagesGracePeriod = 0,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Grace period (in days) after which unregistered GINA accounts are automatically removed (set to 0 to disable)'
            )]
        [Alias('delUnreg')]
        [int]$deleteUnregistered = 0,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customers more detailed description'
            )]
        [string]$description,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = '?????????????????'
            )]
        [string[]]$mailRoutes,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'How many licenses may users of this customers consume for encryption ?'
            )]
        [int]$maximumEncryptionLicenses,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'How many licenses may users of this customers consume for elarge file transfer ?'
            )]
        [int]$maximumLFTLicenses,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Automatically send backup to Customer Admin E-mail'
            )]
        [bool]$sendBackupToAdmin,

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

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

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

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

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

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

        Write-Verbose "Building full request uri"
        $boundParam = @{name=$name}
        $smaParams=@{
            Host=$Host;
            Port=$Port;
            Version=$Version;
        }; # end smaParams
        $uri = New-SMAQueryString -uriPath $uriPath @smaParams; #-qParam $boundParam

        Write-Verbose 'Crafting mandatory $body JSON'
        $bodyht = @{}

        Write-Verbose 'Adding optional values to $body JSON'
        if ($adminEmail) {$bodyht.adminEmail = $adminEmail}
        if ($admins) {$bodyht.admins = $admins}
        if ($backupPassword) {$bodyht.backupPassword = (ConvertFrom-SMASecureString -securePassword $backupPassword)}
        if ($comment) {$bodyht.comment = $comment}
        if ($defaultGINADomain) {$bodyht.defaultGINADomain = $defaultGINADomain}
        if ($deleteOldMessagesGracePeriod) {$bodyht.deleteOldMessagesGracePeriod = $deleteOldMessagesGracePeriod}
        if ($deleteUnregistered) {$bodyht.deleteUnregistered = $deleteUnregistered}
        if ($description) {$bodyht.description = $description}
        if ($mailRoutes) {$bodyht.mailRoutes = $mailRoutes}
        if ($maximumEncryptionLicenses) {$bodyht.maximumEncryptionLicenses = $maximumEncryptionLicenses}
        if ($maximumLFTLicenses) {$bodyht.maximumLFTLicenses = $maximumLFTLicenses}
        if ($sendBackupToAdmin) {$bodyht.sendBackupToAdmin = $sendBackupToAdmin}
        
        $body = $bodyht|ConvertTo-JSON
        Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
        $invokeParam = @{
            Uri         = $uri 
            Method      = 'PUT'
            body        = $body
            Cred        =  $cred
            SkipCertCheck = $SkipCertCheck
        }
        #debug $uri
        Write-Verbose "Call Invoke-SMARestMethod $uri"
        $customerRaw = Invoke-SMARestMethod @invokeParam
        #debug $customerraw
        Write-Verbose 'Returning name of customer'
        $customerRaw.psobject.Properties.Value  
    }
    catch {
        Write-Error "An error occured, see $error"
    }
}

<#
.SYNOPSIS
    Remove a SEPPmail customer
.DESCRIPTION
    This CmdLet lets you delete a SEPPmail customer. You need the name of the customer.
.EXAMPLE
    PS C:\> Remove-SMAcustomer -name 'Fabrikam'
    Delete a customer.
.EXAMPLE
    PS C:\> 'Contoso','Fabrikam'|Remove-SMAcustomer
    Delete a customer by using the pipeline
.EXAMPLE
    PS C:\> Remove-SMAcustomer -name 'Fabrikam' -WhatIf
    Simulate the customer deletion
#>

function Remove-SMAcustomer
{
    [CmdletBinding(DefaultParameterSetName = 'Default',SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            ParameterSetName                = 'Default',
            Position                        = 0,
            HelpMessage                     = 'The customer´s name you want to delete'
            )]
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            ParameterSetName                = 'DeleteAll',
            Position                        = 0,
            HelpMessage                     = 'The customer´s name you want to delete'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all related users of this customer'
            )]
        [switch]$deleteUsers = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all related GINA users of this customer'
            )]
        [switch]$deleteGINAUsers = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all Admin Users of this customer'
            )]
        [switch]$deleteAdminUsers = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all managed domains related to this customer'
            )]
        [switch]$deleteManagedDomains = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all GINA domains related to this customer'
            )]
        [switch]$deleteGINADomains = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all policies of this customer'
            )]
        [switch]$deletePolicies = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Default',
            HelpMessage                     = 'If set, deletes all smarhost credentials used EXCLUSIVELY by this customer'
            )]
        [switch]$deleteSmarthostCredentials = $false,

        [Parameter(
            Mandatory                       = $false,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'DeleteAll',
            HelpMessage                     = 'If set, deletes everything related to this customer'
            )]
        [switch]$deleteEverything = $false,

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

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

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

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

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

    )

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
    }
    process {
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}" -f 'customer', $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=$Host;
                Port=$Port;
                Version=$Version;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;
    
            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri 
                Method      = 'DELETE'
                Cred        =  $cred
                SkipCertCheck = $SkipCertCheck
            }
            if ($PSCmdLet.ShouldProcess($name, "Remove customer")){
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                # Wait-Debugger
                $customerRaw = Invoke-SMARestMethod @invokeParam
                Write-Verbose 'Returning Delete details'
                $customerRaw.psobject.Properties.Value
            }
        }
        catch {
            Write-Error "An error occured, see $error"
        }
    }
    end {

    }

}

<#
.SYNOPSIS
    Export a customer and all its details.
.DESCRIPTION
    This CmdLet lets you export an existing customer.
.EXAMPLE
    PS C:\> $backuppassword = ConvertTo-SecureString -String 'secretbackup' -AsPlainText -Force
    PS C:\> Export-SMACustomer -name 'Fabrikam' -encryptionpassword $backuppassword -path ..\Fabrikam.zip
    Export the customer Fabrikam to a local ZIP-file in the parent folder of the current folder (with a relative path)
    NOTE!: Customer names are case-sensitive
.EXAMPLE
    PS C:\> $backuppassword = ConvertTo-SecureString -String 'secretbackup' -AsPlainText -Force
    PS C:\> Export-SMACustomer -name 'Fabrikam' -encryptionpassword $backuppassword -literalpath c:\temp\Fabrikam.zip
    Export the customer Fabrikam to a local ZIP-file with a literal path
    NOTE!: Customer names are case-sensitive
#>

function Export-SMACustomer
{
    [CmdletBinding(DefaultParameterSetName = 'Path')]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customer name (Case sensitive!)'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Password for encrypted ZIP'
            )]
        [SecureString]$encryptionPassword,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Path',
            HelpMessage                     = 'Relative Path for ZIP-File, i.e. .\contoso.zip'
            )]
        [string]$path,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'LiteralPath',
            HelpMessage                     = 'Literal path for ZIP-File, i.e. c:\temp\contoso.zip'
            )]
        [string]$literalPath,

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

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

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

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

            [Parameter(
                Mandatory=$false
                )]
            [switch]$SkipCertCheck=$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 'customer', $name, 'export'
        
                Write-Verbose "Building full request uri"
                $smaParams=@{
                    Host=$Host;
                    Port=$Port;
                    Version=$Version;
                }; # end smaParams
                $uri = New-SMAQueryString -uriPath $uriPath @smaParams;
        
                Write-verbose "Packing password into body JSON"
                $encryptionPasswordPlain = ConvertFrom-SMASecureString -securePassword $encryptionPassword
        
                $bodyHt = @{
                    encryptionpassword = $encryptionPasswordPlain
                }
                $body = ConvertTo-Json $bodyHt
        
                Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
                $invokeParam = @{
                    Uri         = $uri 
                    Method      = 'POST'
                    body        = $body
                    Cred        =  $cred
                    SkipCertCheck = $SkipCertCheck
                }
        
                Write-Verbose "Call Invoke-SMARestMethod $uri" 
                $ExportRaw = Invoke-SMARestMethod @invokeParam
        
                Write-Verbose "Converting JSON Zip data to ZipFile"
                $bytes = [System.Convert]::FromBase64String($ExportRaw.zippedData)
                if ($pscmdlet.ParameterSetName -eq 'Path') {
                    Write-Verbose "Will create a file according to $path definition"
                    $ZipfileRoot = (Split-Path $path -Parent|resolve-path).Path
                    $ZipfileName = Split-Path $path -leaf
                    $ZipfilePath = Join-Path -Path $ZipFileRoot -ChildPath $ZipFileName
                    [IO.File]::WriteAllBytes($ZipFilePath, $bytes)
                    Write-Information "Written file to $ZipFilePath"
                }
                if ($pscmdlet.ParameterSetName -eq 'literalPath') {
                    $fileParent = Split-Path $literalPath -Parent
                    if (!(test-path $fileparent)) {
                        Write-Verbose "Directory of $literalpath didnt exist, trying to create it"
                        New-Item -ItemType Directory -Path $fileParent
                    }
                    Write-Verbose "Will create a file according to $literalpath definition"
                    [IO.File]::WriteAllBytes($literalpath, $bytes)
                    Write-Information "Written file to $literalPath"
                }
            }
            catch {
                Write-Error "An error occured, see $error"
            }
        }
}
#>

function Import-SMACustomer
{
    [CmdletBinding(DefaultParameterSetName = 'Path',SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customer name (Case sensitive!)'
            )]
        [ValidatePattern('[a-zA-Z0-9\-_]')]
        [string]$name,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Secure password for encrypted ZIP'
            )]
        [SecureString]$encryptionPassword,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'Path',
            HelpMessage                     = 'Relative Path for ZIP-File, i.e. .\contoso.zip'
            )]
        [string]$path,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ParameterSetName                = 'LiteralPath',
            HelpMessage                     = 'Literal path for ZIP-File, i.e. c:\temp\contoso.zip'
            )]
        [string]$literalPath,

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

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

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

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

    try {
        
        Write-Verbose "Creating URI path"
        $uripath = "{0}/{1}" -f 'customer', 'import'
    
        Write-verbose "Creating SMA Query String"
        $smaParams = @{
            Host    = $Host
            Port    = $Port
            Version = $Version
        } # end smaParams
        $uri = New-SMAQueryString -uriPath $uriPath @smaParams

        Write-verbose "Packing password into body JSON"
        $encryptionPasswordPlain = ConvertFrom-SMASecureString -securePassword $encryptionPassword

        $jsonZIP = $null
        Write-Verbose "Convert ZIPFile to JSON Zip Data"
        if ($psCmdLet.ParameterSetName -eq 'Path')
        {
            if (!(Test-Path $path))
            {
                Write-Error "$Path does not exist - please enter a valid path"
                break
            }
            else
            {
                  $truePath = Resolve-Path $path
                $zipContent = [IO.File]::ReadAllBytes($truePath)
                   $jsonZip = [System.Convert]::ToBase64String($zipContent)
            }
        }

        if ($psCmdLet.ParameterSetName -eq 'LiteralPath') {
            if (!(Test-path $literalPath)) {
                Write-Error "$literalPath does not exist - please enter a valid path"
                break
            } else {
                $truePath = Resolve-Path $literalPath
                $zipContent = [IO.File]::ReadAllBytes($truePath)
                $jsonZip = [System.Convert]::ToBase64String($zipContent)
            }
        }

        $bodyHt = @{
            zippedData = $jsonZip
            encryptionpassword = $encryptionPasswordPlain
            name = $name
        }
        $body = ConvertTo-Json $bodyHt

        Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
        $invokeParam = @{
            Uri           = $uri 
            Method        = 'POST'
            body          = $body
            Cred          = $cred
            SkipCertCheck = $SkipCertCheck
        }

        if ($PSCmdLet.ShouldProcess($name,"Import customer")) {
            Write-Verbose "Call Invoke-SMARestMethod $uri" 
            #Wait-Debugger
            Invoke-SMARestMethod @invokeParam
        }

    }
    catch {
        Write-Error "An error occured, see $error"
    }
}

<#
.SYNOPSIS
    Add admins to a customer
.DESCRIPTION
    This CmdLet lets you add administrators to an existing SEPPmail customer.
    You need the e-Mail addresses of the admins.
.EXAMPLE
    PS C:\> Add-SMAcustomerAdmin -customer 'Contoso' -email 'john.doe@contoso.com'
#>

function Add-SMAcustomerAdmin
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            HelpMessage                     = "Admin E-Mail addresses in an array @('john.doe@contoso.com','jane.black@fabrikam.com')"
            )]
        [string[]]$admins,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customer name'
            )]
        [string]$customer,

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

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

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

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

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

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

        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}/{2}" -f 'customer', $customer, 'adminuser'
        }
        catch {
            Write-Error "Error$.categoryInfo happened"
        }
    }
    process {
        try {
            Write-Verbose "Building full request uri"
            $smaParams=@{
                Host=$Host;
                Port=$Port;
                Version=$Version;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;

            Write-verbose "Crafting body ht for list of admins"
            $bodyht = @{
                admins = $admins
            }

            $body = $bodyht|ConvertTo-JSON
            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri 
                Method      = 'POST'
                body        = $body
                Cred        =  $cred
                SkipCertCheck = $SkipCertCheck
                }
            
            if ($PSCmdLet.ShouldProcess($customer,"Adding admin users")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $adminUsers = Invoke-SMARestMethod @invokeParam
                Write-Verbose 'Returning changes'
                $adminusers
                #($userraw.message -split ' ')[3]
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

<#
.SYNOPSIS
    Removes admins from a customer
.DESCRIPTION
    This CmdLet lets you remove administrators from an existing SEPPmail customer.
    You need the e-Mail addresses of the admins and the customers name.
.EXAMPLE
    PS C:\> Remove-SMAcustomerAdmin -customer 'Contoso' -email 'john.doe@contoso.com'
#>

function Remove-SMAcustomerAdmin
{
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            ValueFromPipeline               = $true,
            HelpMessage                     = "Admin E-Mail addresses in an array @('john.doe@contoso.com','jane.black@fabrikam.com')"
            )]
        [string[]]$admins,

        [Parameter(
            Mandatory                       = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage                     = 'Customer name'
            )]
        [string]$customer,

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

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

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

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

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

    begin {
        if (! (verifyVars -VarList $Script:requiredVarList))
        {
            Throw($missingVarsMessage);
        }; # end if
        
        try {
            Write-Verbose "Creating URL path"
            $uriPath = "{0}/{1}/{2}" -f 'customer', $customer, 'adminuser'
        }
        catch {
            Write-Error "Error$.categoryInfo happened"
        }
    }
    process {
        try {
            Write-Verbose "Building full request uri"
            $smaParams=@{
                Host=$Host;
                Port=$Port;
                Version=$Version;
            }; # end smaParams
            $uri = New-SMAQueryString -uriPath $uriPath -qParam $boundParam @smaParams;

            Write-verbose "Crafting body ht for list of admins"
            $bodyht = @{
                admins = $admins
            }

            $body = $bodyht|ConvertTo-JSON
            Write-verbose "Crafting Invokeparam for Invoke-SMARestMethod"
            $invokeParam = @{
                Uri         = $uri 
                Method      = 'PUT'
                body        = $body
                Cred        =  $cred
                SkipCertCheck = $SkipCertCheck
                }
            
            if ($PSCmdLet.ShouldProcess($customer,"Removing admin users")) {
                Write-Verbose "Call Invoke-SMARestMethod $uri"
                $adminUsers = Invoke-SMARestMethod @invokeParam
                Write-Verbose 'Returning changes'
                $adminusers
                #($userraw.message -split ' ')[3]
            }
        }
        catch {
            Write-Error "An error occured, see $error.CategoryInfo"
        }
    }
}

Write-Verbose 'Create CmdLet Alias for Customers' 
$custVerbs = ('Add','Remove','Get','Import','Export','Find','Set')

Foreach ($custverb in $custVerbs) {
    $aliasname1 = $custverb + '-SMACust'
    $aliasname2 = $custverb + '-SMATen'
    $cmdName = $custverb + '-SMACustomer'
    New-Alias -Name $aliasName1 -Value $cmdName
    New-Alias -Name $aliasName2 -Value $cmdName
}

# SIG # Begin signature block
# MIIVzAYJKoZIhvcNAQcCoIIVvTCCFbkCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX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