Skip to content

Conversation

@SamErde
Copy link
Contributor

@SamErde SamErde commented Jan 6, 2026

Description

Forces $diagnosticSettings to be returned as an array, even if only one diagnostic setting object exists. Required for the foreach ($entry in $diagnosticSettings) statement to properly handle the results as an array.

Fixes #1391

Contribution Checklist

Before submitting this PR, please confirm you have completed the following:

  • 📖 Read the guidelines for contributing to this repository.
  • 🧪 Ensure the build and unit tests pass by running /powershell/tests/pester.ps1 on your local system.

 

Join us at the Maester repository discussions 💬 or Entra Discord 🧑‍💻 for more help and conversations!

Forces $diagnosticSettings to be returned as an array, even if only one diagnostic setting object exists. Required for the `foreach ($entry in $diagnosticSettings)` statement to properly handle the results as an array.
Copilot AI review requested due to automatic review settings January 6, 2026 00:57
@SamErde SamErde requested a review from a team as a code owner January 6, 2026 00:57
@SamErde SamErde added the maester-test Related to a Maester test label Jan 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the diagnostic settings retrieval could fail when only a single diagnostic setting object is returned from the API. By wrapping the result in the PowerShell array subexpression operator @(), the variable is guaranteed to be an array, preventing issues with the foreach loop that iterates over the results.

  • Forces $diagnosticSettings to always be an array type, even when a single object is returned
  • Ensures the foreach loop on line 40 properly handles all scenarios (zero, one, or multiple diagnostic settings)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cloudflare-workers-and-pages
Copy link

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 89927d2
Status: ✅  Deploy successful!
Preview URL: https://093f97d5.maester.pages.dev
Branch Preview URL: https://samerde-patch-1.maester.pages.dev

View logs

@SamErde SamErde merged commit 0399a21 into main Jan 19, 2026
13 checks passed
@SamErde SamErde deleted the SamErde-patch-1 branch January 19, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maester-test Related to a Maester test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🪲 MT.1100 fails to analyze Intune diagnostic settings

3 participants