private/Test-MDTInstallDir.ps1
|
function Test-MDTInstallDir { <# .SYNOPSIS Tests whether an MDT installation directory exists .DESCRIPTION Reads Install Dir from the Microsoft Deployment 4 machine registry key and tests that path. If it is empty or does not exist, tests the default Microsoft Deployment Toolkit directory under ProgramFiles. Returns $true when either directory exists; otherwise, returns $false. .EXAMPLE PS> Test-MDTInstallDir Tests the registered and default MDT installation directories. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.Boolean. Returns $true when a tested MDT directory exists; otherwise, returns $false. .NOTES Author: David Segura Company: Recast Software Version: 1.0.0 Date: 2026-08-28 .LINK Test-InstallMDT #> [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) } |