private/Tests/Test-MDTInstallDir.ps1
|
function Test-MDTInstallDir { <# .SYNOPSIS Returns $true when the MDT installation directory exists on disk. .DESCRIPTION Reads the 'Install Dir' value from HKLM:\SOFTWARE\Microsoft\Deployment 4 and tests whether the directory exists. Falls back to the default MDT install location when the registry key is absent. Returns $false when neither the registry path nor the default directory exists on disk. .NOTES Author: David Segura Company: Recast Software Registry key: HKLM:\SOFTWARE\Microsoft\Deployment 4 Registry value: Install Dir Default path: C:\Program Files\Microsoft Deployment Toolkit Dependencies: Windows Features: MDT #> [OutputType([bool])] param () $installDir = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Deployment 4' -Name 'Install Dir' -ErrorAction SilentlyContinue).'Install Dir' if ($installDir -and (Test-Path -Path $installDir)) { return $true } # Fallback to default location (registry key absent but directory may exist) $defaultPath = Join-Path $env:ProgramFiles 'Microsoft Deployment Toolkit' return (Test-Path -Path $defaultPath) } |