- Run a package for each deployment type in Interactive and Silent mode from an elevated console and capture the exit code
- Find the PSADT log and the MSI log of a run and read the key lines
- Locate a failed MSI action in a verbose MSI log
- Interpret the documented PSADT and Windows Installer exit codes
- Work through a pre-handover checklist
A package that has run once has not been tested. Lesson 4 ended with one install and one uninstall. This lesson turns that into a fixed test cycle, explains the two logs every run produces, and lists the exit codes that appear in practice and where each one is documented. It ends with the checklist that a package passes before it goes to the deployment tool.
The test cycle
Each test starts from a known state. For this package that means the clean checkpoint psadt-L5-start of the test VM CL01 for the first install, and the result of the previous step for the rest of the cycle.
| # | Run | Start state | Expected result |
|---|---|---|---|
| 1 | Install, Interactive | psadt-L5-start | Dialogs appear, exit code 0, 7-Zip installed |
| 2 | Install, Silent | After run 1 | No dialogs, exit code 0, MSI step skipped as already installed |
| 3 | Uninstall, Silent | After run 2 | Exit code 0, 7-Zip removed |
| 4 | Uninstall, Silent | After run 3 | Exit code 0, MSI step skipped as not installed |
| 5 | Install, Silent | After run 4 | Exit code 0, 7-Zip installed again |
| 6 | Repair, Silent | After run 5 | Exit code 0, 7-Zip still installed |
Runs 2 and 4 check that the package behaves sensibly when it runs twice. Deployment tools re-run packages, for example after a failed detection, so a second run must not break anything.
How to run a test
Tests run in an elevated Windows PowerShell 5.1 console. Three details matter:
Invoke-AppDeployToolkit.exeis a Windows application, not a console program. PowerShell does not wait for it unlessStart-Process -Waitis used, and only-PassThrureturns the process object with its exit code.-Waitwaits for the launcher and every process it starts, according to theStart-Processdocumentation. If the console does not return, a PSADT dialog may still be open.- According to the 4.1.8 launcher source, the launcher runs the script in PowerShell 7 when
pwshis one of its parent processes. Tests from a PowerShell 7 console therefore do not reproduce what Configuration Manager and Intune do by default. The first lines of the PSADT log show which PowerShell was used (PowerShell Process Path is [...]).
A small helper keeps the runs consistent:
# Run the package with the given deployment type and deploy mode and return the exit code
function Invoke-PackageTest
{
param
(
[Parameter(Mandatory = $true)]
[ValidateSet('Install', 'Uninstall', 'Repair')]
[System.String]$DeploymentType,
[Parameter(Mandatory = $true)]
[ValidateSet('Auto', 'Interactive', 'NonInteractive', 'Silent')]
[System.String]$DeployMode,
[Parameter(Mandatory = $false)]
[System.String]$PackagePath = 'C:\Lab\Packages\7-Zip\26.06\Package'
)
$launcher = Join-Path -Path $PackagePath -ChildPath 'Invoke-AppDeployToolkit.exe'
$arguments = "-DeploymentType $DeploymentType -DeployMode $DeployMode"
$run = Start-Process -FilePath $launcher -ArgumentList $arguments -WorkingDirectory $PackagePath -Wait -PassThru
[PSCustomObject]@{
DeploymentType = $DeploymentType
DeployMode = $DeployMode
ExitCode = $run.ExitCode
Installed = Test-Path -Path 'C:\Program Files\7-Zip\7zFM.exe'
}
}
# Example: run 1 of the test cycle
Invoke-PackageTest -DeploymentType Install -DeployMode InteractiveTesting as SYSTEM
Configuration Manager and Intune run system-context packages as the local SYSTEM account. Differences between an administrator and SYSTEM show up in user-specific paths and registry hives, which this MSI package does not touch. A SYSTEM run is still part of the checklist before handover. A common method is PsExec from Microsoft Sysinternals, introduced in lesson 3, started from an elevated command prompt:
REM Run the package as SYSTEM; -i shows any window in the console session
REM C:\Tools is not on the PATH, so PsExec is called with its full path
C:\Tools\psexec.exe -accepteula -s -i "C:\Lab\Packages\7-Zip\26.06\Package\Invoke-AppDeployToolkit.exe" -DeploymentType Install -DeployMode Silent
echo Exit code: %ERRORLEVEL%PsExec waits for the launcher, and according to the Sysinternals page the error code it returns is that of the started application. Two lines in the PSADT log confirm the context: Current User is [NT AUTHORITY\SYSTEM]. and Session 0 detected but deployment mode was explicitly set to [Silent]. PSADT reports "Session 0" for any run under a system or service account. Other user context topics, such as HKCU settings, are covered in the advanced course.
Where the logs are
With administrator rights, which includes SYSTEM, PSADT 4.1.8 writes both logs to the toolkit log folder. The values below are the defaults from Config\config.psd1.
| Log | Location and name | Written by |
|---|---|---|
| PSADT log | C:\ | The session, from Open-ADTSession to Close-ADTSession |
| MSI log | Same folder (unless MSI.LogPath is set), <name>_ with whitespace removed | msiexec, through the /L*V switch added by Start-ADTMsiProcess |
For the MSI log, the 4.1.8 source takes name and version from the MSI's ProductName and ProductVersion when the product is not installed, and from the installed entry's DisplayName and DisplayVersion (which Windows Installer derives from the same properties) for Uninstall and Repair. For 7-Zip 26.06 (ProductName = 7-Zip 26.06 (x64 edition), ProductVersion = 26.06.00.0), the install run writes IgorPavlov_7-Zip_26.06_x64_EN_01_PSAppDeployToolkit_Install.log and 7-Zip26.06(x64edition)_26.06.00.0_Install.log.
Further defaults that explain what appears in the folder:
LogAppend = $true: a new run of the same package and deployment type appends to the existing log. Each run starts with a dashed divider line and[<InstallName>] install started., so the latest run is at the end of the file.LogMaxSize = 10(MB) andLogMaxHistory = 10: when a session starts and the log is larger than the limit, the log is renamed with a timestamp and a new one begins; at most ten archived files are kept.LogStyle = 'CMTrace': the log uses the CMTrace format, so CMTrace shows severity colours and columns.- Without administrator rights, the toolkit uses
LogPathNoAdminRights($envProgramData\Logs\Software) and appends the user name to the log file name. This depends on whether the process is elevated, not onRequireAdmin: a non-elevated run of this package leaves a short..._PSAppDeployToolkit_Install_<UserName>.logthere that ends with exit code60008. When a test returns60008, this folder is the first place to look.
CMTrace (see lesson 3) is installed with the Configuration Manager client as C:\Windows\CCM\CMTrace.exe and on the site server under cd.latest\SMSSETUP\Tools\, as listed on the CMTrace page on Microsoft Learn. It reads plain-text logs such as Windows Installer logs as well, and Tools > Error Lookup translates a Windows error code. On a test VM without the client, Notepad works too.
Reading a PSADT log
A PSADT log is long, but a first pass needs only a few lines. In CMTrace, errors appear with a red background and warnings with a yellow one. Each message starts with the phase it was written in, for example [Install] :: Executing MSI action [Install]..., and the Component column names the function that wrote it. The messages below are taken from the 4.1.8 source:
| Line contains | Meaning |
|---|---|
Installation is running in [Silent] mode. | The deploy mode the session actually used, after any Auto decision |
Executing MSI action [Install]... | Start-ADTMsiProcess starts its work |
The MSI is already installed on this system. Skipping action [Install]... | The product code was found; nothing was installed |
The MSI is not installed on this system. Skipping action [Uninstall]... | Nothing to uninstall |
Execution completed successfully with exit code [0]. | The MSI returned a success code |
Execution completed successfully with exit code [3010]. A reboot is required. | Success with a reboot code (logged as a warning) |
Execution failed with exit code [1603]. | The MSI failed. For codes that msimsg.dll describes, such as 1618 or 1619, the description follows after a colon instead of the full stop. |
Deployment deferred by the user. | The user chose Defer in the welcome dialog |
[<InstallName>] install completed in [...] seconds with exit code [0]. | The last line of the session, with the exit code passed to the caller |
The last line is logged as information on success, as a warning for 1602 and 1618, and as an error otherwise. Two habits help. First, read the last line of the newest session block: it states the exit code that the deployment tool will see. Second, when that code is not 0, search upwards for the first red line; it usually names the step that failed, and its phase shows whether it happened in Pre-Install, Install or Post-Install.
Reading the MSI log
The MSI log records what happened inside Windows Installer: properties, actions, files and registry changes. When Start-ADTMsiProcess reports a failure, this log contains the reason.
A failed action is recorded with Return value 3. Searching for that string usually leads to the action that started the rollback; the lines just above it state what went wrong. Later matches typically only report that the enclosing sequence ended, so the first match is the one to read. This technique is described in a Windows Installer blog post archived on Microsoft Learn, How to locate the cause of error code 1603 in a verbose MSI log file. The post also notes that the string is written in the language of the operating system, so a localised Windows needs the translated text.
# Show each failed action in the newest MSI install log, with the ten lines above it
$msiLog = Get-ChildItem -Path 'C:\Windows\Logs\Software' -Filter '*_Install.log' |
Where-Object { $_.Name -notlike '*_PSAppDeployToolkit_*' } |
Sort-Object -Property LastWriteTime -Descending |
Select-Object -First 1
Select-String -Path $msiLog.FullName -Pattern 'Return value 3' -Context 10, 0Exit codes
The exit code is the only result a deployment tool receives from the package. The following codes are documented, each with its source.
| Code | Meaning | Source |
|---|---|---|
0 | Success | Windows Installer error codes; PSADT AppSuccessExitCodes |
3010 | Success, restart required | Windows Installer; PSADT AppRebootExitCodes |
1641 | Success, the installer has initiated a restart | Windows Installer; PSADT AppRebootExitCodes |
1602 | The user cancelled; PSADT also uses it when the user defers | Windows Installer; PSADT DeferExitCode in config.psd1 |
1618 | Another installation is already in progress; PSADT also uses it when a dialog times out | Windows Installer; PSADT DefaultExitCode in config.psd1 |
1603 | Fatal error during installation | Windows Installer |
1605 | The product is not installed (rare here, because Start-ADTMsiProcess skips such an uninstall) | Windows Installer |
1619 | The installation package could not be opened | Windows Installer |
60001 | Script error in Invoke-AppDeployToolkit.ps1 | PSADT exit codes |
60008 | The module failed to import, or the session failed to open | PSADT exit codes |
60010, 60011 | The launcher failed before starting PowerShell, or could not run it | PSADT exit codes |
69000–69999 | Range for custom codes in the wrapper script | PSADT exit codes |
How the codes reach the caller in 4.1.8, according to the template and the Start-ADTProcess and Close-ADTSession source:
- When an MSI fails,
Start-ADTMsiProcessstores the MSI's exit code in the session, and the template closes the session with that code. A package whose MSI returns1603exits with1603, not with60001. If the MSI file cannot even be opened, for example because it is damaged,msiexecnever runs; the session holds no MSI code, and the run ends with60001. - When the wrapper fails for another reason, for example a missing file, the template closes the session with
60001. - A run without elevation ends at session start with
60008, as described under the log locations. - Reboot codes from
AppRebootExitCodesare passed through as they are, and the log addsA restart has been flagged as required.The switch-SuppressRebootPassThruon the command line turns them into0. - Before it starts
msiexec, the toolkit waits up toMutexWaitTime(600 seconds by default) for the Windows Installer service to become available, which reduces1618failures when two installations overlap. If the wait runs out, the log showsAnother MSI installation is already in progress..., and the run ends with60001, not1618.
For many Windows Installer codes, Get-ADTMsiExitCodeMessage -MsiExitCode 1618 returns the description text without an open session. It reads the text from msimsg.dll, which has no entry for some codes; for 1603 it returns nothing. Lesson 6 shows how Configuration Manager and Intune interpret these codes.
Pre-handover checklist
A package goes to the deployment tool only when every line is confirmed.
- All six runs of the test cycle return the expected exit code.
- The install run was also performed as SYSTEM with
-DeployMode Silent; its log showsCurrent User is [NT AUTHORITY\SYSTEM]. - The PSADT log of every run ends with the expected exit code; no red lines without an explanation.
- The MSI logs contain no
Return value 3. - After the uninstall,
C:\Program Files\7-Zipand the uninstall registry entry are gone. - The log file names match the install name;
AppRevisionis correct for this build. -
Files\contains only the MSI; its hash matchesNotes.md. -
Notes.mdlists source, hash, product code, command lines, test date and results. - The install and uninstall command lines for the deployment tool are written down (lesson 6).
Common mistakes
The exit code is usually the first symptom. The table lists the codes that appear most often in local tests.
| Symptom | Cause | Fix |
|---|---|---|
Exit code 1603; the PSADT log shows Execution failed with exit code [1603] | An action inside the MSI failed: "A fatal error occurred during installation" | Open the MSI log of that run and read the lines above the first Return value 3 |
Exit code 60001 | "An error occurred in Invoke-AppDeployToolkit.ps1", for example a missing file or a misspelled parameter | Read the newest session block of the PSADT log from the first red line |
Exit code 60008; the log is in C:\ProgramData\Logs\Software | "Failure when importing the module or opening a new session"; in a manual test usually a console without elevation | Repeat the test from a console started as administrator |
Exit code 1602; the log shows Deployment deferred by the user. | The user selected Defer: "A 1602 error code is returned when the defer option is selected" | Expected in an interactive test; how a deployment tool treats 1602 is covered in lesson 6 |
Exit code 1618 | Another installation was in progress, or a PSADT dialog timed out (DefaultExitCode) | Repeat the test when no other installation runs and nobody leaves a dialog open |
Try it
On the Hyper-V host, apply the checkpoint
psadt-L5-startofCL01and start the VM if it is off. If the checkpoint does not exist yet, applypsadt-L4-endand take it:Checkpoint-VM -Name CL01 -SnapshotName psadt-L5-start. Other hypervisors: the equivalent snapshot. Copy thePackagefolder from lesson 4 fromPKG01toC:\Lab\Packages\7-Zip\26.06\PackageonCL01. Expected: a cleanCL01with the package. Check:Test-Path -Path 'C:\Lab\Packages\7-Zip\26.06\Package\Invoke-AppDeployToolkit.exe'returnsTrue.On
CL01, open Windows PowerShell as administrator and defineInvoke-PackageTestfrom this lesson. Expected: the function exists in the session. Check:Get-Command -Name Invoke-PackageTestreturns it.Run the six steps of the test cycle in order and collect the results:
powershell$results = @( Invoke-PackageTest -DeploymentType Install -DeployMode Interactive Invoke-PackageTest -DeploymentType Install -DeployMode Silent Invoke-PackageTest -DeploymentType Uninstall -DeployMode Silent Invoke-PackageTest -DeploymentType Uninstall -DeployMode Silent Invoke-PackageTest -DeploymentType Install -DeployMode Silent Invoke-PackageTest -DeploymentType Repair -DeployMode Silent ) $results | Format-Table -AutoSizeIn run 1, the welcome dialog appears with the buttons Install and Defer. Select Install, and confirm the closing message with OK. Expected: all six runs return
0; theInstalledcolumn readsTrue,True,False,False,True,True.Open the PSADT install log in CMTrace or Notepad. Find the deploy mode line and the final line of each session block. Open the MSI install log next to it. Expected: run 1 shows
Installation is running in [Interactive] mode., the other runs show[Silent]; the log of run 2 containsSkipping action [Install], and the uninstall log of run 4 containsSkipping action [Uninstall]. Check:Select-String -Path 'C:\Windows\Logs\Software\IgorPavlov_7-Zip_26.06_x64_EN_01_PSAppDeployToolkit_Install.log' -Pattern 'Installation is running in [' -SimpleMatch.Provoke a failure: rename
Files\7z2606-x64.msito7z2606-x64.msi.bak, runInvoke-PackageTest -DeploymentType Uninstall -DeployMode Silent, then rename the file back. Find the red lines in the uninstall log. Expected: exit code60001; the log showsFailed to find the file [7z2606-x64.msi].andAn unhandled error within [Invoke-AppDeployToolkit.ps1] has occurred., and no MSI log is written, becausemsiexecnever starts. Check:Select-String -Path 'C:\Windows\Logs\Software\*_PSAppDeployToolkit_Uninstall.log' -Pattern 'Failed to find the file' -SimpleMatch.Provoke a deferral: run
Invoke-PackageTest -DeploymentType Install -DeployMode Interactiveonce more and select Defer in the welcome dialog. Expected: exit code1602; the log showsDeployment deferred by the user.and a yellow final line.Test as SYSTEM: on the host, revert
CL01topsadt-L5-start. Copy thePackagefolder again andPsExec.exetoC:\ToolsonCL01, then run the PsExec command from Testing as SYSTEM in an elevated command prompt. The command callsC:\Tools\psexec.exewith its full path: an elevated prompt starts inC:\Windows\System32, and a barepsexec.exeends with "is not recognized as an internal or external command". Expected:Exit code: 0, and the PSADT install log containsCurrent User is [NT AUTHORITY\SYSTEM].Check:Select-String -Path 'C:\Windows\Logs\Software\IgorPavlov_7-Zip_26.06_x64_EN_01_PSAppDeployToolkit_Install.log' -Pattern 'NT AUTHORITY\SYSTEM' -SimpleMatch.On
PKG01, work through the pre-handover checklist of this lesson line by line and record the results, the test date and the PSADT version inNotes.md. The line on the command lines stays open until lesson 6. Expected: every line except the command lines is confirmed or has a written reason. Check:Get-Content -Path 'C:\Lab\Packages\7-Zip\26.06\Notes.md'.On the host, revert
CL01topsadt-L5-start, then take the checkpointpsadt-L5-end. Expected:CL01is clean. Check:Get-VMCheckpoint -VMName CL01listspsadt-L5-end.
Notes.md together with the PSADT version used.
Check your understanding
- Why does a test call the launcher through
Start-Process -Wait -PassThruinstead of running it directly?
Answer
Invoke-AppDeployToolkit.exe is a Windows application. PowerShell does not wait for it when it is called directly, so the exit code is not available when the command returns. Start-Process -Wait -PassThru waits for the end of the run and returns a process object whose ExitCode holds the result.
- A package returns
1603. Which log is read first, and what is searched for?
Answer
The PSADT log first, to confirm that Start-ADTMsiProcess failed with 1603 and in which phase. Then the MSI log of that action, searching for the first Return value 3 and reading the lines above it.
- What is the difference between
60001and60008, and where is the log of a60008run without elevation?
Answer
60008 means the module could not be imported or the session could not be opened, so none of the deployment phases ran. 60001 means the session was open and an error occurred in the wrapper script. A run without elevation ends with 60008 and writes its log to C:\ProgramData\Logs\Software, with the user name at the end of the file name.
- Why are a second install run and a second uninstall run part of the test cycle?
Answer
Deployment tools run packages again, for example after a detection mismatch or a retry. The package must handle an already installed or already removed product without failing. Start-ADTMsiProcess skips the action in both cases and logs why.
- Which two exit codes does PSADT itself use for user decisions and dialog timeouts, and where are they configured?
Answer
1602 when the user defers (DeferExitCode) and 1618 when a dialog times out (DefaultExitCode). Both are set in the UI section of Config\config.psd1.
Summary
- A fixed test cycle covers install, uninstall and repair, including second runs, and starts from a clean checkpoint.
- Tests run from an elevated Windows PowerShell 5.1 console through
Start-Process -Wait -PassThru, inInteractiveandSilentmode; one install is repeated as SYSTEM with PsExec. - With administrator rights, the PSADT log and the MSI log sit side by side in
C:\Windows\Logs\Software; a non-elevated run logs toC:\ProgramData\Logs\Software. - The last line of the PSADT session states the exit code; the first
Return value 3marks the failed action in the MSI log. - Exit codes come from Windows Installer, from
config.psd1and from the documented PSADT range; the checklist confirms the package before handover.
Sources
- PSAppDeployToolkit 4.1 — Exit codes — https://psappdeploytoolkit.com/docs/4.1.x/reference/exit-codes (4.1.x, checked 2026-11-30)
- PSAppDeployToolkit 4.1 — FAQ (deferral exit code) — https://psappdeploytoolkit.com/docs/4.1.x/getting-started/faq (4.1.x, checked 2026-11-30)
- PSAppDeployToolkit 4.1 — Invoke-AppDeployToolkit — https://psappdeploytoolkit.com/docs/4.1.x/deployment-concepts/invoke-appdeploytoolkit (4.1.x, checked 2026-11-30)
- MsiExec.exe and InstMsi.exe error messages — https://learn.microsoft.com/en-us/windows/win32/msi/error-codes (ms.date 2023-02-08, checked 2026-11-30)
- How to locate the cause of error code 1603 in a verbose MSI log file (archived blog) — https://learn.microsoft.com/en-us/archive/blogs/astebner/how-to-locate-the-cause-of-error-code-1603-in-a-verbose-msi-log-file (link from the lesson text; archived)
- PsExec — https://learn.microsoft.com/en-us/sysinternals/downloads/psexec (ms.date 2026-11-05, checked 2026-11-30)
- PSAppDeployToolkit 4.1 — Get-ADTMsiExitCodeMessage — https://psappdeploytoolkit.com/docs/4.1.x/reference/functions/Get-ADTMsiExitCodeMessage (4.1.x, checked 2026-11-30)
- CMTrace — https://learn.microsoft.com/en-us/intune/configmgr/core/support/cmtrace (link from the lesson text; to be checked in stage 7)
- PSAppDeployToolkit 4.1.8 source code (launcher,
Close-ADTSession,Start-ADTMsiProcess,Start-ADTProcess,strings.psd1) — https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/tree/4.1.8 (tag 4.1.8)