private/Tests/Test-PwshPSHome.ps1

function Test-PwshPSHome {
    <#
    .SYNOPSIS
        Returns $true when the current PowerShell session is not running from a
        Microsoft Store (MSIX) or WinGet installation.
 
    .DESCRIPTION
        Checks whether $PSHOME is located under the WindowsApps directory, which
        indicates an MSIX-packaged install (Microsoft Store or WinGet). This type
        of installation runs in a virtualized app container that cannot mount WIM
        images or access system paths reliably, and therefore does not support
        PowerShell DISM operations required by this module.
 
        Returns $false and emits a warning when a WindowsApps install is detected.
        Use this test before any DISM or WIM-mount operations.
 
    .OUTPUTS
        [bool] $false when $PSHOME contains '\WindowsApps\'; $true otherwise.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Install PowerShell 7 from an MSI: https://aka.ms/powershell
 
    Dependencies:
      Executables: dism.exe, winget
    #>

    [OutputType([bool])]
    param ()

    if ($PSHOME -like '*\WindowsApps\*') {
        Write-Warning "[$($MyInvocation.MyCommand.Name)] This module requires the MSI installation of PowerShell 7. The MSIX (Microsoft Store) and WinGet installations of PowerShell run in a virtualized app container and do not support PowerShell DISM operations. Install PowerShell 7 from an MSI at https://aka.ms/powershell and try again."
        return $false
    }

    return $true
}