Create a license deployable package
        Create a deployable package with a license file inside
    .PARAMETER LicenseFile
        Path to the license file that you want to have inside a deployable package
        Path to the template zip file for creating a deployable package with a license file
        Default path is the same as the aos service "PackagesLocalDirectory\bin\CustomDeployablePackage\"
    .PARAMETER OutputPath
        Path where you want the generated deployable package stored
        Default value is: "C:\temp\\"
        PS C:\> New-D365ISVLicense -LicenseFile "C:\temp\ISVLicenseFile.txt"
        This will take the "C:\temp\ISVLicenseFile.txt" file and locate the "" template file under the "PackagesLocalDirectory\bin\CustomDeployablePackage\".
        It will extract the "", load the ISVLicenseFile.txt and compress (zip) the files into a deployable package.
        The package will be exported to "C:\temp\\"
        Author: Mötz Jensen (@splaxi)
        Author: Szabolcs Eötvös

function New-D365ISVLicense {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
    param (

        [Parameter(Mandatory = $true, Position = 1)]
        [string] $LicenseFile,

        [string] $Path = "$Script:BinDirTools\CustomDeployablePackage\",

        [string] $OutputPath = "C:\temp\\"


    begin {
        $oldprogressPreference = $global:progressPreference
        $global:progressPreference = 'silentlyContinue'
    process {

        if (-not (Test-PathExists -Path $Path, $LicenseFile -Type "Leaf")) { return }

        $null = New-Item -Path (Split-Path $OutputPath -Parent) -ItemType Directory -ErrorAction SilentlyContinue

        Unblock-File $Path
        Unblock-File $LicenseFile

        $ExtractionPath = [System.IO.Path]::GetTempPath()

        $packageTemp = Join-Path $ExtractionPath ((Get-Random -Maximum 99999).ToString())

        Write-PSFMessage -Level Verbose -Message "Extracting the template zip file to $packageTemp." -Target $packageTemp
        Expand-Archive -Path $Path -DestinationPath $packageTemp

        $licenseMergePath = Join-Path $packageTemp "AosService\Scripts\License"
        if (Test-Path -Path $licenseMergePath) {
            Get-ChildItem -Path $licenseMergePath | Remove-Item -Force -ErrorAction SilentlyContinue
        else {
            $null = New-Item -Path $licenseMergePath -ItemType Directory -ErrorAction SilentlyContinue
        Write-PSFMessage -Level Verbose -Message "Copying the license file into place."
        Copy-Item -Path $LicenseFile -Destination $licenseMergePath

        Write-PSFMessage -Level Verbose -Message "Compressing the folder into a zip file and storing it at $OutputPath" -Target $OutputPath
        Compress-Archive -Path "$packageTemp\*" -DestinationPath $OutputPath -Force

            File = $OutputPath

    end {
        $global:progressPreference = $oldprogressPreference