private/Test-WindowsAdkPath.ps1

function Test-WindowsAdkPath {
    <#
    .SYNOPSIS
        Tests whether a registered Windows ADK directory exists
 
    .DESCRIPTION
        Reads KitsRoot10 from the 32-bit and 64-bit Windows Kits Installed Roots
        machine registry keys, in that order, and tests each nonempty path.
        Returns $true when a referenced path exists. Returns $false when neither
        registry value references an existing path.
 
    .EXAMPLE
        PS> Test-WindowsAdkPath
 
        Tests registered Windows ADK root paths for an existing directory.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        System.Boolean. Returns $true when a registered KitsRoot10 path exists;
        otherwise, returns $false.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 1.0.0
        Date: 2026-08-28
    #>

    [OutputType([bool])]
    param ()

    $kitsRegPaths = @(
        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots',
        'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots'
    )

    foreach ($regPath in $kitsRegPaths) {
        $kitsRoot = (Get-ItemProperty -Path $regPath -Name 'KitsRoot10' -ErrorAction SilentlyContinue).KitsRoot10
        if ($kitsRoot -and (Test-Path -Path $kitsRoot)) {
            return $true
        }
    }

    return $false
}