Test-Battery - How to Implement?

I’d like to include a battery test so if not on battery the installation won’t run.

What do I need to do to implement this ?

This must be simple but I can’t work it out.

I haven’t made use of this function myself but the script linked below has a good example you can copy.

## Abort with error code 1618 (fast retry) if machine is on battery
If(-not (Test-Battery)) { Exit-Script 1618 }

BIOS update PSAppDeployToolkit script

Thanks. I thought it would just have a built in parameter like disk space has. Would I just add the suggested code into deploy-application.ps1 ?

I alisojust saw the code below which cab added to you installation section

    # Continue checking AC until plugged in.
    [bool]$Continue = $false
    do {
        [hashtable]$testBattery = Test-Battery -PassThru
        if(($testBattery).IsUsingACPower) {
            $Continue = $true
        } elseif ( $ActiveUser -and $isParentServiceUI ) {
            Show-InstallationWelcome -AllowDefer:$false -ForceCountdown 60 -Customtext
            Start-Sleep -Seconds 1
        } else {
            $mainExitCode = 1603
        }
    } until ($Continue -eq $true -or $mainExitCode -eq 1603)