######################################
# CONFIGURE CUSTOMER PROVISIONING HERE #
######################################
$serial = ""
$org = ""
######################################

$keys = @{
    "SerialId" = $serial;
    "OrgID" = $org;
    "EnableAzureAd" = 1
}

$registryPath = "HKLM:\SOFTWARE\Smoothwall\Safeguarding Client"

if(!(Test-Path -Path $registryPath))
{
    New-Item -Path $registryPath -Force 
}

foreach ($key in $keys.Keys) 
{
    if (![string]::IsNullOrWhiteSpace($keys.Item($key)))
    {
        if ($keys.Item($key) -is [string]) 
        {
            New-ItemProperty -Path $registryPath -Name $key -Value $keys.Item($key) -PropertyType STRING -Force 
        }
        elseif ($keys.Item($key) -is [int])
        {
            New-ItemProperty -Path $registryPath -Name $key -Value $keys.Item($key) -PropertyType DWORD -Force 
        }
        else 
        {
            Write-Output("Unsupported type for key [$key]")
        }
    }
    else
    {
        try  
        {
            Get-ItemPropertyValue -Path $registryPath -Name $key
            Remove-ItemProperty -Path $registryPath -Name $key -Force
        }
        catch
        {
            # Key doesn't exists, do nothing
        }
    }
}
