Looking for the PowerShell equivalent of this cmd error-check:
IF %ERRORLEVEL% NEQ 0
Here is the PowerShell code I am trying to write:
Since dism.exe is an external program, you'd want to check the $LASTEXITCODE automatic variable:
dism.exe
$LASTEXITCODE
dism /online /andsoon if($LASTEXITCODE -ne 0) { # Add your capability }