Private/Install/Invoke-PWSHYBKPIVMsiInstall.ps1

function Invoke-PWSHYBKPIVMsiInstall {
    <#
    .SYNOPSIS
        Runs msiexec.exe to silently install a downloaded MSI package.
    .DESCRIPTION
        Invokes msiexec.exe /i <path> /quiet /norestart and waits for completion. Exit code 0
        (success) and 3010 (success, reboot required) are treated as success; any other exit
        code throws. Extracted into its own function so Install-PWSHYBKPIVTool can be unit
        tested with a mock instead of actually running an installer.
    .PARAMETER MsiPath
        Full path to the downloaded .msi file.
    .EXAMPLE
        Invoke-PWSHYBKPIVMsiInstall -MsiPath 'C:\Temp\yubico-piv-tool-2.7.3-win64.msi'
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string] $MsiPath
    )

    $arguments = @('/i', "`"$MsiPath`"", '/quiet', '/norestart')
    $process   = Start-Process -FilePath 'msiexec.exe' -ArgumentList $arguments -Wait -PassThru -NoNewWindow

    if ($process.ExitCode -ne 0 -and $process.ExitCode -ne 3010) {
        throw "msiexec.exe exited with code $($process.ExitCode) while installing '$MsiPath'."
    }
}