Convert-WindowsAutopilotProfile.ps1

<#PSScriptInfo
 
.VERSION 1.0
 
.GUID fd810044-ad83-42fb-8724-69128972e75b
 
.AUTHOR Michael Niehaus
 
.COMPANYNAME Microsoft
 
.COPYRIGHT
 
.TAGS Windows AutoPilot
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
Version 1.0: Original published version.
 
#>


<#
.SYNOPSIS
Interprets and displays Windows Autopilot profile settings.
.DESCRIPTION
This script reads the Autopilot profile settings from the AutopilotDDSZTDFile.json file captured by the MDMDiagnosticsTool and displays them to the console.
.PARAMETER File
The full path and name of the file to be read, e.g. C:\AutopilotDDSZTDFile.json.
.PARAMETER Config
The full path and name of the file to be read, e.g. C:\AutopilotDDSZTDFile.json.
.EXAMPLE
.\Convert-WindowsAutopilotProfile.ps1 -File C:\AutopilotDDSZTDFile.json
.EXAMPLE
.\Convert-WindowsAutopilotProfile.ps1 -Config 28
 
#>


[CmdletBinding()]
param(
    [Parameter(Mandatory=$True,ParameterSetName='Full')] [String] $File = "", 
    [Parameter(Mandatory=$True,ParameterSetName='Config')] [String] $Config = "0"
)

Process
{
    if ($File -ne "")
    {

        # Read the file and convert it to JSON
        $json = Get-Content -Path $File | ConvertFrom-Json
        $p = @{}
        foreach ($property in $json.PSObject.Properties) {
            $p[$property.Name] = $property.Value
        }

        # Write the profile name
            Write-Host " "
        Write-Host "Profile name: $($p.DeploymentProfileName)" -ForegroundColor Yellow 
        Write-Host " "

        # Determine the profile type
        if (($p.CloudAssignedOobeConfig -band 128+64+32) -gt 0)
        {
            $pType = "Self-deploying"
        }
        elseif ($p.CloudAssignedDomainJoinMethod -eq 0)
        {
            $pType = "User-driven (Azure AD Join)"
        }
        else
        {
            $pType = "User-driven (Hybrid Azure AD Join)"
        }
        Write-Host "Profile type: $pType"

        # Write out identifiers
        Write-Host "Azure AD tenant: $($p.CloudAssignedTenantDomain)"
        Write-Host "Azure AD tenant ID: $($p.CloudAssignedTenantId)"
        Write-Host "Azure AD device ID: $($p.AadDeviceId)"
        Write-Host "Autopilot device ID: $($p.ZtdRegistrationId)"
        Write-Host "MDM ID: $($p.CloudAssignedMdmId)"
    }
    else
    {
        $p = @{}
        $p["CloudAssignedOobeConfig"] = $Config
    }

    # Write flags
        Write-Host " "
    Write-Host "OOBE config: $($p.CloudAssignedOobeConfig)"
    if (($p.CloudAssignedOobeConfig -band 1024) -gt 0)
    {
        Write-Host "Skip keyboard: Yes 1 - - - - - - - - - -"
    }
    else
    {
        Write-Host "Skip keyboard: No 0 - - - - - - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 512) -gt 0)
    {
        Write-Host "Enable patch download: Yes - 1 - - - - - - - - -"
    }
    else
    {
        Write-Host "Enable patch download: No - 0 - - - - - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 256) -gt 0)
    {
        Write-Host "Skip Windows upgrade UX: Yes - - 1 - - - - - - - -"
    }
    else
    {
        Write-Host "Skip Windows upgrade UX: No - - 0 - - - - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 128) -gt 0)
    {
        Write-Host "AAD TPM Required: Yes - - - 1 - - - - - - -"
    }
    else
    {
        Write-Host "AAD TPM Required: No - - - 0 - - - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 64) -gt 0)
    {
        Write-Host "AAD device auth: Yes - - - - 1 - - - - - -"
    }
    else
    {
        Write-Host "AAD device auth: No - - - - 0 - - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 32) -gt 0)
    {
        Write-Host "TPM attestation: Yes - - - - - 1 - - - - -"
    }
    else
    {
        Write-Host "TPM attestation: No - - - - - 0 - - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 16) -gt 0)
    {
        Write-Host "Skip EULA: Yes - - - - - - 1 - - - -"
    }
    else
    {
        Write-Host "Skip EULA: No - - - - - - 0 - - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 8) -gt 0)
    {
        Write-Host "Skip OEM registration: Yes - - - - - - - 1 - - -"
    }
    else
    {
        Write-Host "Skip OEM registration: No - - - - - - - 0 - - -"
    }
    if (($p.CloudAssignedOobeConfig -band 4) -gt 0)
    {
        Write-Host "Skip express settings: Yes - - - - - - - - 1 - -"
    }
    else
    {
        Write-Host "Skip express settings: No - - - - - - - - 0 - -"
    }
    if (($p.CloudAssignedOobeConfig -band 2) -gt 0)
    {
        Write-Host "Disallow admin: Yes - - - - - - - - - 1 -"
    }
    else
    {
        Write-Host "Disallow admin: No - - - - - - - - - 0 -"
    }

    if ($File -ne "")
    {

        # Write other flags
        if ($p.CloudAssignedForcedEnrollment -eq "1")
        {
            Write-Host "Forced enrollment: Yes"
        }
        else
        {
            Write-Host "Forced enrollment: No"
        }
        if ($p.CloudAssignedAutopilotUpdateDisabled -eq "1")
        {
            Write-Host "Autopilot update: Yes"
        }
        else
        {
            Write-Host "Autopilot update: No"
        }
        Write-Host " "

        # Write other properties
        Write-Host "Language: $($p.CloudAssignedLanguage)"
        Write-Host "Region: $($p.CloudAssignedRegion)"
        Write-Host "Device name template: $($p.CloudAssignedDeviceName)"
    }

    Write-Host " "
}