Skip to content

SPInstallPrereqs: Improve diagnostics for PrerequisiteInstaller exit code 1000 - #1483

Open
raandree wants to merge 4 commits into
dsccommunity:masterfrom
raandree:fix/#1482
Open

SPInstallPrereqs: Improve diagnostics for PrerequisiteInstaller exit code 1000#1483
raandree wants to merge 4 commits into
dsccommunity:masterfrom
raandree:fix/#1482

Conversation

@raandree

@raandree raandree commented Jul 23, 2026

Copy link
Copy Markdown

Pull Request (PR) description

MSFT_SPInstallPrereqs previously handled the undocumented
PrerequisiteInstaller.exe exit code 1000 through the generic default
branch ("The prerequisite installer ran with the following unknown exit code
1000"
). That message does not direct operators to the native
PrerequisiteInstaller*.log, where the actual failed prerequisite is recorded
(in the reported case, a failed IIS feature install caused by missing offline
Windows feature payloads).

This PR adds an explicit 1000 branch to the exit-code switch that:

  • Treats 1000 as a hard failure — it does not retry and does not classify it
    as success or restart-required.
  • Does not set $global:DSCMachineStatus, so exit code 1000 never
    requests a DSC reboot.
  • Writes an error through the existing Add-SPDscEvent pattern
    (EntryType 'Error', EventID 100) and throws an actionable exception that
    references exit code 1000, PrerequisiteInstaller*.log, the temporary
    directory of the account running the resource, and the SXSpath parameter,
    with guidance to use matching Windows Server installation media or preinstall
    the required Windows features from that source.

Microsoft documents 3010 (not 1000) as the restart-required result; that
distinction is preserved. Behavior for exit codes 0, 1, 2, 1001,
3010, -1, -2147467259, and the generic default branch is unchanged. The
change does not parse, copy, or attach native installer logs — the native log
remains the source of truth for the underlying failure. Resource
troubleshooting documentation and the changelog are updated accordingly.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
    Entry should say what was changed and how that affects users (if applicable), and
    reference the issue being resolved (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof and comment-based
    help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@raandree
raandree requested review from a team and ykuijs as code owners July 23, 2026 19:52
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

SPInstallPrereqs now treats prerequisite installer exit code 1000 as an actionable hard failure without requesting a reboot. Tests, documentation, and the changelog cover this behavior. Build settings also update module output, task loading, and related configuration.

Changes

Prerequisite installer failure handling

Layer / File(s) Summary
Exit code 1000 handling
SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1
Adds a dedicated exit-code branch that records native-log and offline SXSpath guidance, then throws without requesting a reboot.
Validation and documentation
tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1, SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/Readme.md, CHANGELOG.md
Tests the error, event, installer invocation, and reboot status; documents troubleshooting guidance and records the fix in the unreleased changelog.
Offline prerequisite coverage
tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1
Refines SharePoint build-specific parameter expectations and initializes reboot status in feature-installation scenarios.

Build configuration updates

Layer / File(s) Summary
Module build and task configuration
build.yaml
Updates module output settings, nested-module configuration, task patterns, test exclusions, release file quoting, and documentation regex formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The build.yaml changes appear unrelated to the exit-code 1000 diagnostics issue and its documentation/testing scope. Remove the build.yaml changes unless they are required for this fix, or explain their necessity in the issue context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: improved diagnostics for PrerequisiteInstaller exit code 1000.
Description check ✅ Passed The description is directly related to the exit-code 1000 diagnostics fix and accompanying docs/tests.
Linked Issues check ✅ Passed The PR adds actionable failure handling for exit code 1000, preserves 3010 reboot behavior, and updates docs and tests as requested.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 29-34: Update the SPInstallPrereqs changelog entry to reference
issue 1482 using the required linked “[issue `#1482`](...)” format, and wrap
PrerequisiteInstaller.exe, PrerequisiteInstaller*.log, SXSpath, and exit code
1000 in inline-code Markdown.</code>

In `@SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1`:
- Around line 1198-1203: Replace the literal exit-code-1000 message assigned to
$message with a localized string lookup that accepts the temporary-directory
path as its format argument. Add the corresponding string key to every
localization resource and update the relevant tests to validate the key and
formatted diagnostic, preserving the existing guidance and $env:TEMP value.

In `@SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/Readme.md`:
- Around line 58-64: Update the “PrerequisiteInstaller.exe exit code 1000”
heading and its explanatory sentence in the prerequisite documentation to format
the executable name as inline code, preserving the surrounding wording and
Markdown structure.

In `@tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1`:
- Line 276: Update the Pester mocks and assertions in the affected tests around
Add-SPDscEvent to use Pester v5 syntax: remove the empty mock body and replace
each Assert-MockCalled assertion with an exact Should -Invoke assertion,
preserving the existing command, invocation count, and parameter expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a162e2e2-3e06-4aeb-8d6b-e6acd69a6edd

📥 Commits

Reviewing files that changed from the base of the PR and between b6ee731 and 80c2ce3.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1
  • SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/Readme.md
  • tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1

Comment thread CHANGELOG.md
Comment on lines +29 to +34
- SPInstallPrereqs
- Improved diagnostics for PrerequisiteInstaller.exe exit code 1000. This undocumented
failure result is now treated as a hard failure that throws an actionable error pointing
to the native PrerequisiteInstaller*.log and, for offline installations, to the SXSpath
parameter, instead of a generic unknown exit code message. Exit code 1000 no longer
requests a reboot (#1482).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the required changelog issue-reference and Markdown format.

The new entry should link issue 1482 using the required format and inline-code file names/literals:

-- SPInstallPrereqs
-  - Improved diagnostics for PrerequisiteInstaller.exe exit code 1000. This undocumented
-    failure result is now treated as a hard failure that throws an actionable error pointing
-    to the native PrerequisiteInstaller*.log and, for offline installations, to the SXSpath
-    parameter, instead of a generic unknown exit code message. Exit code 1000 no longer
-    requests a reboot (`#1482`).
+- _SPInstallPrereqs_
+  - Improved diagnostics for `PrerequisiteInstaller.exe` exit code `1000`. This
+    undocumented failure result is now treated as a hard failure that throws an
+    actionable error pointing to the native `PrerequisiteInstaller*.log` and,
+    for offline installations, to the `SXSpath` parameter, instead of a generic
+    unknown exit code message. Exit code `1000` no longer requests a reboot
+    ([issue `#1482`](https://github.com/dsccommunity/SharePointDsc/issues/1482)).

As per path instructions, changelog issue references must use the linked [issue #<issue_number>](...) format.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- SPInstallPrereqs
- Improved diagnostics for PrerequisiteInstaller.exe exit code 1000. This undocumented
failure result is now treated as a hard failure that throws an actionable error pointing
to the native PrerequisiteInstaller*.log and, for offline installations, to the SXSpath
parameter, instead of a generic unknown exit code message. Exit code 1000 no longer
requests a reboot (#1482).
- _SPInstallPrereqs_
- Improved diagnostics for `PrerequisiteInstaller.exe` exit code `1000`. This
undocumented failure result is now treated as a hard failure that throws an
actionable error pointing to the native `PrerequisiteInstaller*.log` and,
for offline installations, to the `SXSpath` parameter, instead of a generic
unknown exit code message. Exit code `1000` no longer requests a reboot
([issue `#1482`](https://github.com/dsccommunity/SharePointDsc/issues/1482)).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` around lines 29 - 34, Update the SPInstallPrereqs changelog
entry to reference issue 1482 using the required linked “[issue `#1482`](...)”
format, and wrap PrerequisiteInstaller.exe, PrerequisiteInstaller*.log, SXSpath,
and exit code 1000 in inline-code Markdown.</code>

Source: Path instructions

Comment on lines +1198 to +1203
$message = ("The prerequisite installer failed with undocumented exit code 1000. " + `
"Review the latest PrerequisiteInstaller*.log in the temporary directory " + `
"of the account running this resource ($env:TEMP). For offline " + `
"installations, verify SXSpath points to the SXS store from matching " + `
"Windows Server installation media, or preinstall all required Windows " + `
"features from that source.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Localize the new user-facing error message.

This branch adds a user-facing message as a literal string. Add a localized string key for the exit-code-1000 diagnostic, passing the temporary path as a format argument, and update the corresponding localization resources and tests.

As per path instructions, all strings must be localized using string keys.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1`
around lines 1198 - 1203, Replace the literal exit-code-1000 message assigned to
$message with a localized string lookup that accepts the temporary-directory
path as its format argument. Add the corresponding string key to every
localization resource and update the relevant tests to validate the key and
formatted diagnostic, preserving the existing guidance and $env:TEMP value.

Source: Path instructions

Comment on lines +58 to +64
### PrerequisiteInstaller.exe exit code 1000

Exit code `1000` is an undocumented failure result from the
PrerequisiteInstaller.exe. In contrast to exit code `3010`, which Microsoft
documents as the restart-required result, `1000` is undocumented and does
not point to a specific cause by itself. This resource treats it as a hard
failure: it does not retry the installation and does not request a reboot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Format the executable name as inline code.

PrerequisiteInstaller.exe is a file name and should be formatted as inline code in both the heading and the explanatory sentence.

-### PrerequisiteInstaller.exe exit code 1000
+### `PrerequisiteInstaller.exe` exit code `1000`

-... from the PrerequisiteInstaller.exe.
+... from the `PrerequisiteInstaller.exe`.

As per path instructions, Markdown file names and paths must use inline-code formatting.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### PrerequisiteInstaller.exe exit code 1000
Exit code `1000` is an undocumented failure result from the
PrerequisiteInstaller.exe. In contrast to exit code `3010`, which Microsoft
documents as the restart-required result, `1000` is undocumented and does
not point to a specific cause by itself. This resource treats it as a hard
failure: it does not retry the installation and does not request a reboot.
### `PrerequisiteInstaller.exe` exit code `1000`
Exit code `1000` is an undocumented failure result from the
`PrerequisiteInstaller.exe`. In contrast to exit code `3010`, which Microsoft
documents as the restart-required result, `1000` is undocumented and does
not point to a specific cause by itself. This resource treats it as a hard
failure: it does not retry the installation and does not request a reboot.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/Readme.md` around lines 58 -
64, Update the “PrerequisiteInstaller.exe exit code 1000” heading and its
explanatory sentence in the prerequisite documentation to format the executable
name as inline code, preserving the surrounding wording and Markdown structure.

Source: Path instructions


It "Should call the prerequisite installer from the set method and throw an actionable error for undocumented exit code 1000 without requesting a reboot" {
Mock -CommandName Start-Process { return @{ ExitCode = 1000 } }
Mock -CommandName Add-SPDscEvent { }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the repository’s Pester v5 mock syntax.

Omit the empty mock body and replace Assert-MockCalled with exact Should -Invoke assertions:

- Mock -CommandName Add-SPDscEvent { }
+ Mock -CommandName Add-SPDscEvent

- Assert-MockCalled -CommandName Start-Process -Scope It
+ Should -Invoke -CommandName Start-Process -Exactly -Times 1 -Scope It

- Assert-MockCalled -CommandName Add-SPDscEvent -Scope It -Times 1 -Exactly -ParameterFilter {
+ Should -Invoke -CommandName Add-SPDscEvent -Exactly -Times 1 -Scope It -ParameterFilter {

As per path instructions, Pester v5 tests must use Should -Invoke and omit empty mock blocks.

Also applies to: 293-296

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1` at line
276, Update the Pester mocks and assertions in the affected tests around
Add-SPDscEvent to use Pester v5 syntax: remove the empty mock body and replace
each Assert-MockCalled assertion with an exact Should -Invoke assertion,
preserving the existing command, invocation count, and parameter expectations.

Source: Path instructions

raandree and others added 2 commits July 29, 2026 20:45
The 'offline mode, with SXSstore specified' context always used the SharePoint 2016 offline parameter list, so Set-TargetResource threw 'In offline mode for version 16 parameter DotNet472/DotNet48 is required' for the SP2019 and SPSE stubs. The failure was masked because a previous context leaked a truthy global:DSCMachineStatus, which made the SXS branch return before the offline parameter validation. Adding the exit code 1000 test reset that flag to 0 and exposed the defect.

Select the required parameters per SharePoint version and reset global:DSCMachineStatus in each test so the context no longer depends on leaked state.

Co-authored-by: AI Assistant <ai@example.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1 (1)

289-292: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Cover the complete exit-code-1000 diagnostic contract.

Add environment-independent assertions for temporary directory and matching Windows Server installation media; the current checks do not protect those documented guidance strings.

Proposed fix
                     $exception.Exception.Message | Should -Match 'PrerequisiteInstaller\*\.log'
                     $exception.Exception.Message | Should -Match 'SXSpath'
+                    $exception.Exception.Message | Should -Match 'temporary directory'
+                    $exception.Exception.Message | Should -Match 'matching Windows Server installation media'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1` around
lines 289 - 292, Extend the assertions in the exit-code-1000 test around
$exception.Exception.Message to also match the documented guidance for the
temporary directory and matching Windows Server installation media. Use stable,
environment-independent message fragments and preserve the existing checks for
1000, PrerequisiteInstaller*.log, and SXSpath.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1`:
- Around line 289-292: Extend the assertions in the exit-code-1000 test around
$exception.Exception.Message to also match the documented guidance for the
temporary directory and matching Windows Server installation media. Use stable,
environment-independent message fragments and preserve the existing checks for
1000, PrerequisiteInstaller*.log, and SXSpath.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c9d645e-4427-4574-bdcf-c39cfbfc014f

📥 Commits

Reviewing files that changed from the base of the PR and between 628bc8a and 9c028fe.

📒 Files selected for processing (1)
  • tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPInstallPrereqs: Improve diagnostics for PrerequisiteInstaller exit code 1000

1 participant