Private/Get-IcdRoot.ps1

# Copyright 2019 David Haymond.
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.

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
}