Skip to content

Conversation

@jorgeasaurus
Copy link
Contributor

Add Comprehensive Failure Reporting and Enhanced Export Capabilities

Fixes #74

Summary

This PR introduces a comprehensive suite of reporting functions for Intune assignments, enabling administrators to quickly identify and analyze deployment issues across applications, compliance policies, and configuration policies. The changes also improve cross-platform compatibility with enhanced macOS support. When using command-line parameters, all summary reports show data for all items without filtering, while granular filtering by name remains available in interactive mode.

What's Changed

New Reporting Functions

Core Summary Functions

  1. Get-AppsInstallSummaryReport (Lines 1012-1076)

    • Retrieves detailed installation statistics for all or specific applications
    • Calculates success rates, failure counts, and deployment status
    • Supports searching by app name
    • Returns comprehensive metrics including installed, failed, pending, and not installed counts
  2. Get-CompliancePolicyDeviceSummaryReport (Lines 1078-1228)

    • Generates compliance status summaries for device compliance policies
    • Supports filtering by policy name, ID, or platform (Windows, iOS, Android, macOS)
    • Calculates compliance rates and device counts by status
    • Includes platform-specific filtering capabilities
  3. Get-ConfigurationPolicyDeviceSummaryReport (Lines 1230-1509)

    • Provides deployment status for configuration policies
    • Handles both Settings Catalog and Device Configuration policies
    • Calculates success rates and failure metrics
    • Supports filtering by policy name or platform

Failure Analysis Functions

  1. Get-AppInstallFailuresReport (Lines 1511-1552)

    • Filters applications with failure rates above configurable threshold (default 60%)
    • Calculates failure rate based on actual FailedCount: (FailedCount / TotalCount) * 100
    • Excludes apps with no devices (TotalCount = 0) from analysis
    • Returns results sorted by failure rate (highest first)
  2. Get-CompliancePolicyFailuresReport (Lines 1554-1594)

    • Identifies compliance policies with high non-compliance rates
    • Supports filtering by policy name and platform
    • Automatically includes all policies when no specific policy is specified
    • Calculates non-compliance rate as (100 - ComplianceRate)
  3. Get-ConfigurationPolicyFailuresReport (Lines 1596-1636)

    • Detects configuration policies with high failure rates
    • Calculates failure rate: ((NonCompliantCount + ErrorCount) / TotalDevices) * 100
    • Supports filtering by policy name and platform
    • Includes all policies by default when no filter is specified

📊 New Menu Options

image image

Added six new reporting options to the main menu (Lines 1748-1753):

  • Option 12: App Install Summary Report
  • Option 13: App Install Failures (>60% failure rate)
  • Option 14: Compliance Policy Deployment Summary
  • Option 15: Compliance Policy Failures (>60% non-compliance)
  • Option 16: Configuration Policy Deployment Summary
  • Option 17: Configuration Policy Failures (>60% failure rate)

🎯 Parameter Mode Behavior

When using the script with command-line switches (-ShowAppInstallSummary, -ShowComplianceSummary, -ShowConfigurationSummary):

  • Reports automatically show data for all apps/policies without filtering
  • No name-based filtering parameters are available in parameter mode
  • This ensures consistent, comprehensive summaries for automation scenarios

For granular filtering by specific app or policy names, use the interactive mode (menu-driven interface).

🖥️ Enhanced macOS Compatibility

Updated Export-ResultsIfRequested Function (Lines 1787-1842)

  • Added macOS detection using built-in $IsMacOS variable
  • On macOS, automatically saves to user's Downloads folder: ~/Downloads/IntuneAssignmentChecker_Reports/
  • Bypasses Windows-specific Show-SaveFileDialog on macOS
  • Generates timestamped filenames when no default is provided
  • Shows export path to user for transparency

📁 Export Functionality

All reporting options (12-17) now support CSV export with:

  • Interactive export prompt when not using -ExportToCSV parameter
  • Proper ArrayList conversion to prevent type conversion errors
  • Descriptive default filenames:
    • AppInstallSummary.csv
    • AppInstallFailures.csv
    • CompliancePolicySummary.csv
    • CompliancePolicyFailures.csv
    • ConfigurationPolicySummary.csv
    • ConfigurationPolicyFailures.csv

Technical Implementation Details

Key Features of Reporting Functions

  1. Consistent Error Handling: All functions include try-catch blocks with detailed error messages
  2. Progress Tracking: Functions use Write-Progress for long-running operations
  3. Flexible Filtering: Support for name-based and platform-based filtering
  4. Batch Processing: Optimized API calls for better performance with large datasets
  5. Null Safety: Proper handling of empty results and missing data

Data Processing

  • All functions return structured PSCustomObjects for consistent data handling
  • Automatic calculation of derived metrics (success rates, failure percentages)
  • Support for both interactive and parameter-based execution modes

Testing Recommendations

  1. Test all new menu options (12-17) in interactive mode
  2. Verify export functionality on both Windows and macOS
  3. Test with various failure thresholds (default 60%)
  4. Validate parameter mode functionality
  5. Test with empty result sets to ensure proper handling
  6. Verify platform filtering works correctly
  7. Test with large datasets to ensure performance

Breaking Changes

None - all changes are backward compatible.

Migration Notes

Users on macOS will now see exports saved to their Downloads folder instead of file dialog prompts. The folder location is: ~/Downloads/IntuneAssignmentChecker_Reports/

…mpliance policies

- Introduced new parameters for showing app install summary, compliance policy summary, and configuration policy summary.
- Implemented functions to retrieve app install summaries, compliance policy device summaries, and configuration policy device summaries.
- Added reporting functions for app install failures, compliance policy failures, and configuration policy failures with a threshold of 60%.
- Updated the menu to include options for accessing the new reports.
- Enhanced export functionality for the new report types.
@ugurkocde ugurkocde requested a review from Copilot August 4, 2025 22:41
@ugurkocde ugurkocde self-assigned this Aug 4, 2025

This comment was marked as outdated.

jorgeasaurus and others added 5 commits August 4, 2025 15:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jorgeasaurus jorgeasaurus requested a review from Copilot August 4, 2025 23:01
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

This PR introduces comprehensive failure reporting and enhanced export capabilities for Intune assignments, enabling administrators to quickly identify and analyze deployment issues across applications, compliance policies, and configuration policies. The changes also improve cross-platform compatibility with enhanced macOS support.

Key changes include:

  • Six new reporting functions for summarizing installation/deployment metrics and identifying failures
  • Six new menu options (12-17) providing access to deployment metrics and failure analysis
  • Enhanced macOS compatibility with automatic Downloads folder exports
  • Parameter mode support for automated reporting without user interaction

}
default {
Write-Host "Invalid choice, please select 1-11, 98, 99, or 0." -ForegroundColor Red
Write-Host "Invalid choice, please select 1-17, 98, 99, or 0." -ForegroundColor Red
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The valid menu option range is hardcoded and will need manual updates when new options are added. Consider making this dynamic based on the actual available menu options to reduce maintenance overhead.

Suggested change
Write-Host "Invalid choice, please select 1-17, 98, 99, or 0." -ForegroundColor Red
Write-Host ("Invalid choice, please select one of: " + ($validMenuOptions -join ', ') + ".") -ForegroundColor Red

Copilot uses AI. Check for mistakes.
jorgeasaurus and others added 3 commits August 4, 2025 16:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Perschall22
Copy link

Hello,

Hopping in to ask if the main file will be changed soon? Whenever I downloaded from the repository, it has the older version.

@jorgeasaurus
Copy link
Contributor Author

I've addressed both review comments from Copilot:

1. ✅ Removed Duplicate macOS Check (Line 1640)

Eliminated the redundant macOS check code block that was duplicating logic from lines 1630-1638. The duplicate block has been removed to improve maintainability and reduce potential for bugs.

Before: Two identical if ($IsMacOS) blocks
After: Single macOS check at line 1630

2. ✅ Dynamic Menu Option Validation

Implemented dynamic menu validation using an array of valid options instead of hardcoding the valid range in the error message.

Changes:

  • Added $validMenuOptions array at line 1880 containing all valid menu choices: 1-17, 98, 99, 0
  • Updated the default case error message at line 8424 to dynamically display valid options using $validMenuOptions -join ', '

Before:

Write-Host "Invalid choice, please select 1-17, 98, 99, or 0." -ForegroundColor Red

After:

Write-Host ("Invalid choice, please select one of: " + ($validMenuOptions -join ', ') + ".") -ForegroundColor Red

Benefits:

  • Future menu additions only require updating the array in one place
  • More maintainable and less error-prone
  • Automatically reflects current valid options in error messages

@jorgeasaurus jorgeasaurus requested a review from Copilot October 11, 2025 16:25
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +1322 to +1324
# Note: The Microsoft URI uses "Compliace" (not "Compliance")—this is intentionally matching Microsoft's official endpoint spelling.
$response = Invoke-MgGraphRequest -Method POST `
-Uri "$GraphEndpoint/beta/deviceManagement/reports/microsoft.graph.getDeviceStatusSummaryByCompliacePolicyReport" `
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'Compliacce' to 'Compliance' in the URI.

Copilot uses AI. Check for mistakes.
Comment on lines +1758 to +1762
$failureRate = 100 - $_.SuccessRate
$failureRate -ge $FailureThreshold
} | ForEach-Object {
# Add failure rate for easier display
$_ | Add-Member -MemberType NoteProperty -Name "FailureRate" -Value (100 - $_.SuccessRate) -Force
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Consider using a consistent calculation method across all failure rate calculations. The Get-ConfigurationPolicyFailuresReport calculates failure rate differently than Get-AppInstallFailuresReport which uses the Get-FailureRate function.

Suggested change
$failureRate = 100 - $_.SuccessRate
$failureRate -ge $FailureThreshold
} | ForEach-Object {
# Add failure rate for easier display
$_ | Add-Member -MemberType NoteProperty -Name "FailureRate" -Value (100 - $_.SuccessRate) -Force
$failureRate = Get-FailureRate $_
$failureRate -ge $FailureThreshold
} | ForEach-Object {
# Add failure rate for easier display
$_ | Add-Member -MemberType NoteProperty -Name "FailureRate" -Value (Get-FailureRate $_) -Force

Copilot uses AI. Check for mistakes.
jorgeasaurus and others added 3 commits October 11, 2025 12:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Assignment failures intune

3 participants