private/Step-BuildBootRemoveWinpeshl.ps1

#Requires -PSEdition Core

function Step-BuildBootRemoveWinpeshl {
    <#
    .SYNOPSIS
        Removes winpeshl.ini from the mounted WinPE image
 
    .DESCRIPTION
        Tests for Windows\System32\winpeshl.ini under global BuildMedia.MountPath and
        forcibly removes the file when present. The function makes no change when the
        file does not exist.
 
    .EXAMPLE
        PS> Step-BuildBootRemoveWinpeshl
 
        Removes the mounted image's winpeshl.ini file when present.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        None.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 0.1.0
        Date: 2026-08-28
 
        Requires global BuildMedia.MountPath. Permanently deletes winpeshl.ini from the
        mounted image when it exists.
    #>

    [CmdletBinding()]
    param ()

    $MountPath = $global:BuildMedia.MountPath

    $Winpeshl = "$MountPath\Windows\System32\winpeshl.ini"
    if (Test-Path $Winpeshl) {
        Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] Removing WinRE winpeshl.ini"
        Remove-Item -Path $Winpeshl -Force
    }
}