private/Get-SplitterUiPreflight.ps1

function Get-SplitterUiPreflight {
    [CmdletBinding()]
    param(
        [string]
        $SourceIso,

        [scriptblock]
        $GetOscdimgPathScript
    )

    $checks = @()

    $isElevated = $false
    try {
        $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
        $principal = [Security.Principal.WindowsPrincipal]::new($currentIdentity)
        $isElevated = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
    }
    catch {
        $isElevated = $false
    }

    $checks += [pscustomobject]@{
        Name = 'Elevation'
        Passed = $isElevated
        Message = if ($isElevated) {
            'Running elevated.'
        }
        else {
            'Not elevated. ISO mount and some DISM steps can fail without elevation.'
        }
    }

    $dismCommand = Get-Command -Name 'dism.exe' -ErrorAction SilentlyContinue
    $checks += [pscustomobject]@{
        Name = 'DISM'
        Passed = $null -ne $dismCommand
        Message = if ($dismCommand) {
            "Found dism.exe at $($dismCommand.Source)."
        }
        else {
            'dism.exe was not found on PATH.'
        }
    }

    $oscdimgPath = $null
    if ($null -eq $GetOscdimgPathScript) {
        throw 'Get-SplitterUiPreflight requires GetOscdimgPathScript. Pass the captured Get-OscdimgPath helper.'
    }

    try {
        $getOscdimgPathParams = @{
            ErrorAction = 'Stop'
        }
        $oscdimgPath = & $GetOscdimgPathScript @getOscdimgPathParams
    }
    catch {
        $oscdimgPath = $null
    }

    $checks += [pscustomobject]@{
        Name = 'Oscdimg'
        Passed = -not [string]::IsNullOrWhiteSpace($oscdimgPath)
        Message = if ($oscdimgPath) {
            "Found oscdimg.exe at $oscdimgPath."
        }
        else {
            'oscdimg.exe was not found. Install Windows ADK deployment tools.'
        }
    }

    if ([string]::IsNullOrWhiteSpace($SourceIso)) {
        $checks += [pscustomobject]@{
            Name = 'Source ISO'
            Passed = $false
            Message = 'Source ISO is empty.'
        }
    }
    else {
        $sourceExists = Test-Path -LiteralPath $SourceIso
        $checks += [pscustomobject]@{
            Name = 'Source ISO'
            Passed = $sourceExists
            Message = if ($sourceExists) {
                "Found source ISO at $SourceIso."
            }
            else {
                "Source ISO does not exist at $SourceIso."
            }
        }
    }

    $passedCount = @($checks | Where-Object { $_.Passed }).Count

    [pscustomobject]@{
        Passed = $passedCount -eq $checks.Count
        PassedCount = $passedCount
        TotalCount = $checks.Count
        Checks = $checks
    }
}