m.miloch.dev ← PSADT v4 — Your First PackageCourse
Lesson 5 of 640 minFree course

Testing locally and reading logs

A repeatable local test cycle for a PSADT 4.1 package: which runs to perform, where the PSADT and MSI logs are written, how to read them, which exit codes are documented, and what to check before handover.

In this lesson
  • 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.

#RunStart stateExpected result
1Install, Interactivepsadt-L5-startDialogs appear, exit code 0, 7-Zip installed
2Install, SilentAfter run 1No dialogs, exit code 0, MSI step skipped as already installed
3Uninstall, SilentAfter run 2Exit code 0, 7-Zip removed
4Uninstall, SilentAfter run 3Exit code 0, MSI step skipped as not installed
5Install, SilentAfter run 4Exit code 0, 7-Zip installed again
6Repair, SilentAfter run 5Exit 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.exe is a Windows application, not a console program. PowerShell does not wait for it unless Start-Process -Wait is used, and only -PassThru returns the process object with its exit code.
  • -Wait waits for the launcher and every process it starts, according to the Start-Process documentation. 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 pwsh is 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:

powershell · 30 lines
# 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 Interactive

Testing 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:

bat
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.

LogLocation and nameWritten by
PSADT logC:\Windows\Logs\Software\<InstallName>_PSAppDeployToolkit_<DeploymentType>.logThe session, from Open-ADTSession to Close-ADTSession
MSI logSame folder (unless MSI.LogPath is set), <name>_<version>_<Action>.log with whitespace removedmsiexec, 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) and LogMaxHistory = 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 on RequireAdmin: a non-elevated run of this package leaves a short ..._PSAppDeployToolkit_Install_<UserName>.log there that ends with exit code 60008. When a test returns 60008, 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 containsMeaning
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.

powershell
# 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, 0

Exit codes

The exit code is the only result a deployment tool receives from the package. The following codes are documented, each with its source.

CodeMeaningSource
0SuccessWindows Installer error codes; PSADT AppSuccessExitCodes
3010Success, restart requiredWindows Installer; PSADT AppRebootExitCodes
1641Success, the installer has initiated a restartWindows Installer; PSADT AppRebootExitCodes
1602The user cancelled; PSADT also uses it when the user defersWindows Installer; PSADT DeferExitCode in config.psd1
1618Another installation is already in progress; PSADT also uses it when a dialog times outWindows Installer; PSADT DefaultExitCode in config.psd1
1603Fatal error during installationWindows Installer
1605The product is not installed (rare here, because Start-ADTMsiProcess skips such an uninstall)Windows Installer
1619The installation package could not be openedWindows Installer
60001Script error in Invoke-AppDeployToolkit.ps1PSADT exit codes
60008The module failed to import, or the session failed to openPSADT exit codes
60010, 60011The launcher failed before starting PowerShell, or could not run itPSADT exit codes
69000–69999Range for custom codes in the wrapper scriptPSADT 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-ADTMsiProcess stores the MSI's exit code in the session, and the template closes the session with that code. A package whose MSI returns 1603 exits with 1603, not with 60001. If the MSI file cannot even be opened, for example because it is damaged, msiexec never runs; the session holds no MSI code, and the run ends with 60001.
  • 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 AppRebootExitCodes are passed through as they are, and the log adds A restart has been flagged as required. The switch -SuppressRebootPassThru on the command line turns them into 0.
  • Before it starts msiexec, the toolkit waits up to MutexWaitTime (600 seconds by default) for the Windows Installer service to become available, which reduces 1618 failures when two installations overlap. If the wait runs out, the log shows Another MSI installation is already in progress..., and the run ends with 60001, not 1618.

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 shows Current 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-Zip and the uninstall registry entry are gone.
  • The log file names match the install name; AppRevision is correct for this build.
  • Files\ contains only the MSI; its hash matches Notes.md.
  • Notes.md lists 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.

SymptomCauseFix
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 parameterRead 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 elevationRepeat 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 1618Another 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

  1. On the Hyper-V host, apply the checkpoint psadt-L5-start of CL01 and start the VM if it is off. If the checkpoint does not exist yet, apply psadt-L4-end and take it: Checkpoint-VM -Name CL01 -SnapshotName psadt-L5-start. Other hypervisors: the equivalent snapshot. Copy the Package folder from lesson 4 from PKG01 to C:\Lab\Packages\7-Zip\26.06\Package on CL01. Expected: a clean CL01 with the package. Check: Test-Path -Path 'C:\Lab\Packages\7-Zip\26.06\Package\Invoke-AppDeployToolkit.exe' returns True.

  2. On CL01, open Windows PowerShell as administrator and define Invoke-PackageTest from this lesson. Expected: the function exists in the session. Check: Get-Command -Name Invoke-PackageTest returns it.

  3. 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 -AutoSize

    In 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; the Installed column reads True, True, False, False, True, True.

  4. 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 contains Skipping action [Install], and the uninstall log of run 4 contains Skipping 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.

  5. Provoke a failure: rename Files\7z2606-x64.msi to 7z2606-x64.msi.bak, run Invoke-PackageTest -DeploymentType Uninstall -DeployMode Silent, then rename the file back. Find the red lines in the uninstall log. Expected: exit code 60001; the log shows Failed to find the file [7z2606-x64.msi]. and An unhandled error within [Invoke-AppDeployToolkit.ps1] has occurred., and no MSI log is written, because msiexec never starts. Check: Select-String -Path 'C:\Windows\Logs\Software\*_PSAppDeployToolkit_Uninstall.log' -Pattern 'Failed to find the file' -SimpleMatch.

  6. Provoke a deferral: run Invoke-PackageTest -DeploymentType Install -DeployMode Interactive once more and select Defer in the welcome dialog. Expected: exit code 1602; the log shows Deployment deferred by the user. and a yellow final line.

  7. Test as SYSTEM: on the host, revert CL01 to psadt-L5-start. Copy the Package folder again and PsExec.exe to C:\Tools on CL01, then run the PsExec command from Testing as SYSTEM in an elevated command prompt. The command calls C:\Tools\psexec.exe with its full path: an elevated prompt starts in C:\Windows\System32, and a bare psexec.exe ends with "is not recognized as an internal or external command". Expected: Exit code: 0, and the PSADT install log contains Current 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.

  8. 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 in Notes.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'.

  9. On the host, revert CL01 to psadt-L5-start, then take the checkpoint psadt-L5-end. Expected: CL01 is clean. Check: Get-VMCheckpoint -VMName CL01 lists psadt-L5-end.

Note
The expected messages and codes follow from the 4.1.8 source code and the string file of the template. A lab run is the final confirmation; any difference is worth noting in Notes.md together with the PSADT version used.

Check your understanding

  1. Why does a test call the launcher through Start-Process -Wait -PassThru instead 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.

  1. 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.

  1. What is the difference between 60001 and 60008, and where is the log of a 60008 run 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.

  1. 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.

  1. 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, in Interactive and Silent mode; 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 to C:\ProgramData\Logs\Software.
  • The last line of the PSADT session states the exit code; the first Return value 3 marks the failed action in the MSI log.
  • Exit codes come from Windows Installer, from config.psd1 and from the documented PSADT range; the checklist confirms the package before handover.

Sources

Next: Lesson 6: Handover to ConfigMgr and Intune

Download the one-pager for this lesson (PDF, 126 KB) ↓