Private/Get-IcdRoot.ps1

# SPDX-FileCopyrightText: © 2022 David Haymond <david@davidhaymond.dev>
#
# SPDX-License-Identifier: GPL-3.0-or-later

function Get-IcdRoot {
    $regKey = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots"

    if (Test-Path -Path $regKey) {
        $kitsRoot = (Get-ItemProperty -Path $regKey).KitsRoot10

        if (!$kitsRoot) {
            return $null
        }

        $icdRoot = Join-Path -Path $kitsRoot -ChildPath 'Assessment and Deployment Kit\Imaging and Configuration Designer\x86'

        if (Test-Path -Path $icdRoot) {
            return $icdRoot
        }
    }

    return $null
}