Skip to content

Add Remediation cmdlets#5

Open
hjorslev wants to merge 5 commits intomainfrom
Remediation
Open

Add Remediation cmdlets#5
hjorslev wants to merge 5 commits intomainfrom
Remediation

Conversation

@hjorslev
Copy link
Owner

This PR adds the following cmdlets:

Get-IntuneRemediationSummary

Retrieves remediation summary statistics for all Intune proactive remediations.

Get-IntuneRemediationDeviceStatus

Retrieves per-device run state and pre/post remediation output for a specific Intune proactive remediation.

@hjorslev hjorslev requested a review from Copilot March 13, 2026 20:29
@hjorslev hjorslev self-assigned this Mar 13, 2026
@hjorslev hjorslev added the enhancement New feature or request label Mar 13, 2026
Copy link

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

Adds two new Intune Remediation-focused PowerShell cmdlets that query Microsoft Graph (beta) to surface proactive remediation summary metrics and per-device run state details, along with supporting helper logic and Pester test coverage.

Changes:

  • Introduces Get-IntuneRemediationSummary to list remediations and map runSummary/history counters into a consistent summary output.
  • Introduces Get-IntuneRemediationDeviceStatus to retrieve per-device run states (including pre/post detection output) for a remediation by name or id.
  • Adds Get-FirstPropertyValue helper plus Pester tests, and updates README with new examples.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/functions/public/Remediation/Get-IntuneRemediationSummary.ps1 New cmdlet for remediation summary statistics with history fallback and flexible payload-shape handling.
src/functions/public/Remediation/Get-IntuneRemediationDeviceStatus.ps1 New cmdlet for per-device remediation run state retrieval by Name/Id.
src/functions/private/Get-FirstPropertyValue.ps1 New helper to resolve values from direct properties, dictionaries, or AdditionalProperties.
tests/public/Remediation/Get-IntuneRemediationSummary.Tests.ps1 Test coverage for summary mapping, missing fields defaults, payload variations, and error handling.
tests/public/Remediation/Get-IntuneRemediationDeviceStatus.Tests.ps1 Test coverage for name/id parameter sets, not-found behavior, run-states error behavior, and pipeline binding.
tests/private/Get-FirstPropertyValue.Tests.ps1 Test coverage for helper behavior including AdditionalProperties and valid zero values.
README.md Documents the new cmdlets and adds usage/output examples.

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

Comment on lines +230 to +240
$historyNoIssue = ($historyData | ForEach-Object {
[int](Get-FirstPropertyValue -InputObject $_ -PropertyNames @('noIssueDeviceCount', 'noIssueCount', 'withoutIssues') -DefaultValue 0)
} | Measure-Object -Maximum).Maximum

$historyDetectFailed = ($historyData | ForEach-Object {
[int](Get-FirstPropertyValue -InputObject $_ -PropertyNames @('detectFailedDeviceCount', 'issueDetectedDeviceCount', 'issueCount', 'withIssues') -DefaultValue 0)
} | Measure-Object -Maximum).Maximum

$historyRemediated = ($historyData | ForEach-Object {
[int](Get-FirstPropertyValue -InputObject $_ -PropertyNames @('remediatedDeviceCount', 'issueRemediatedDeviceCount', 'issueFixedCount', 'issueFixed') -DefaultValue 0)
} | Measure-Object -Sum).Sum
Comment on lines +238 to +240
$historyRemediated = ($historyData | ForEach-Object {
[int](Get-FirstPropertyValue -InputObject $_ -PropertyNames @('remediatedDeviceCount', 'issueRemediatedDeviceCount', 'issueFixedCount', 'issueFixed') -DefaultValue 0)
} | Measure-Object -Sum).Sum
Copy link

Copilot AI commented Mar 13, 2026

@hjorslev I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

hjorslev and others added 2 commits March 13, 2026 21:50
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants