Patch/Register-PatchHelper.ps1

<#
.SYNOPSIS
    Configures default parameters for PatchHelper
.DESCRIPTION
    Configures default parameters for PatchHelper. Such as default instance to install patches and extension to and URL adress of the remote server to report patch installation.
.EXAMPLE
    Register-PatchHelper -instanceName BC140 -customerName "our-beloved-customer2" -reportURL "https://report.com:443/mothership" -patchFolder C:\Patches\
.NOTES
#>

function Register-PatchHelper {
    [Alias("rgph")]
    [CmdletBinding()]
    param(
        # Default destination BC instance where objects should be imported to.
        [Parameter(Mandatory = $True, ValueFromPipeline)]
        [ArgumentCompleter({ Import-NavModule -Admin; Get-NAVServerInstance | % { $_.ServerInstance -replace ".*\$", "" } })]
        [string]$instanceName,
        # Name of the dealer to be reported
        [Parameter(Mandatory = $true)]
        [string]$customerName,
        # URL of the endpoint for reporting
        [Parameter(Mandatory = $true)]
        [string]$reportURL,
        # Default patch source folder
        [Parameter(Mandatory = $false)]
        [string]$patchFolder
    )
    begin {
        $ErrorActionPreference = "Stop"
    }
    process {
        Set-Variable -scope Script -Name PatchHelperConfig -Value @{
            "ReportURL" = $reportURL
            "CustomerName" = $customerName
            "DefaultInstance" = $instanceName
            "DefaultPatchFolder" = $patchFolder
        }
        $PatchHelperConfigFile = Join-Path "$Env:ProgramData\ADSPatchHelper" "PatchHelper.config.json"
        $PatchHelperConfig | ConvertTo-Json | Out-File $PatchHelperConfigFile
    }
    end {
    }
}

Export-ModuleMember -Alias * -Function *