functions/Register-EWsGuiAADAppData.ps1

function Register-EWsGuiAADAppData {
    <#
    .SYNOPSIS
    Function to register ClientID, TenantID and ClientSecret to the EWSGui powershell module.
 
    .DESCRIPTION
    Function to register ClientID, TenantID and ClientSecret to the EWSGui powershell module.
     
    .PARAMETER ClientID
    String parameter with the ClientID (or AppId) of your AzureAD Registered App.
 
    .PARAMETER TenantID
    String parameter with the TenantID your AzureAD tenant.
 
    .PARAMETER ClientSecret
    String parameter with the Client Secret which is configured in the AzureAD App.
     
    .EXAMPLE
    PS C:\> Register-EWsGuiAADAppData -ClientID "your app client ID" -TenantID "Your tenant ID" -ClientSecret "your Secret passcode"
 
    The script will register these values in the EWSGui module to be used automatically.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [String] $ClientID,

        [Parameter(Mandatory = $true)]
        [String] $TenantID,

        [Parameter(Mandatory = $true)]
        [String] $ClientSecret
    )

    begin {
        if ( $ClientID -eq '' -or $TenantID -eq '' -or $CertificateThumbprint -eq '' ) {
            throw "Either ClientID, TenantID or ClientSecret are null or empty."
        }
    }

    process {
        Write-PSFMessage -Level Important -Message "Registering ClientID string to EWSGui Module."
        Set-PSFConfig -Module EwsGui -Name "ClientID" -Value $ClientID -Description "AppID of your Azure Registered App" -AllowDelete -PassThru | Register-PSFConfig
        
        Write-PSFMessage -Level Important -Message "Registering TenantID string to EWSGui Module."
        Set-PSFConfig -Module EwsGui -Name "TenantID" -Value $TenantID -Description "TenantID where your Azure App is registered." -AllowDelete -PassThru | Register-PSFConfig
        
        Write-PSFMessage -Level Important -Message "Registering ClientSecret string to EWSGui Module."
        Set-PSFConfig -Module EwsGui -Name "ClientSecret" -Value $clientSecret -Description "ClientSecret passcode for your Azure App" -AllowDelete -PassThru | Register-PSFConfig
    }

    end {

    }
}