ANAVEM
Languagefr
How to Configure Intune Device Cleanup Rules for Automatic Stale Device Removal

How to Configure Intune Device Cleanup Rules for Automatic Stale Device Removal

Set up automated device cleanup rules in Microsoft Intune to hide inactive devices that haven't checked in for 30-270 days, keeping your environment clean and organized.

March 30, 2026 15 min
mediumintune 8 steps 15 min

Why Configure Intune Device Cleanup Rules?

Managing device inventory in Microsoft Intune becomes increasingly complex as organizations scale. Without proper cleanup procedures, your Intune console fills with stale, orphaned, and inactive devices that haven't checked in for months or even years. These ghost devices skew reporting metrics, complicate compliance assessments, and make it difficult to identify truly active endpoints in your environment.

Device cleanup rules in Microsoft Intune provide an automated solution to this challenge. These rules automatically hide inactive devices from your admin console and reports based on configurable inactivity thresholds ranging from 30 to 270 days. As of 2026, Microsoft has enhanced these capabilities with platform-level targeting, allowing you to create specific cleanup rules for Windows, iOS, Android, and macOS devices with different thresholds tailored to each platform's usage patterns.

What Makes Device Cleanup Rules Essential for Modern IT Management?

The key benefit of device cleanup rules lies in their soft-delete approach. Unlike aggressive device retirement policies, cleanup rules simply hide inactive devices without triggering wipe commands or certificate revocation. This means if a device that was hidden due to inactivity comes back online and still has a valid Intune management certificate, it automatically reappears in your console without requiring re-enrollment.

However, there's an important distinction to understand: cleanup rules only affect device visibility in Intune. The devices remain in Microsoft Entra ID and continue to consume licenses until separately addressed. This tutorial covers both Intune cleanup rules and complementary Entra ID cleanup procedures to provide complete environment hygiene. You'll learn to implement automated cleanup workflows that maintain accurate device inventories while preventing accidental removal of legitimately offline devices.

Implementation Guide

Full Procedure

01

Verify Your Administrative Permissions

Before configuring device cleanup rules, confirm you have the necessary permissions. Navigate to the Microsoft Intune admin center and check your role assignments.

Open your browser and go to https://intune.microsoft.com. Sign in with your administrative account and navigate to Tenant administration > Roles > My permissions.

Verify you have one of these roles:

  • Intune Service Administrator (full access)
  • Custom role with these specific permissions:
    • Managed Device Cleanup Rules/Update
    • Managed Device Cleanup Settings/Update
    • Organization/Read
    • Managed devices/Read
Pro tip: If you don't have the required permissions, request them from your Global Administrator before proceeding. Custom roles provide more granular control if you need to limit access.

Verification: You should see your assigned roles listed under "My permissions". If you have the correct permissions, you'll be able to access the Device cleanup rules section in the next step.

02

Access Device Cleanup Rules Configuration

Navigate to the device cleanup rules configuration area within the Intune admin center. This is where you'll create and manage all your cleanup policies.

From the Intune admin center main dashboard:

  1. Click Devices in the left navigation pane
  2. Under the "Organize devices" section, click Device cleanup rules
  3. You'll see the device cleanup rules overview page showing any existing rules

The interface displays current rules, their status, and the number of devices affected by each rule. If this is your first time setting up cleanup rules, the list will be empty.

Warning: Device cleanup rules are a soft-delete mechanism. They hide devices from the Intune console but do NOT remove them from Microsoft Entra ID. Plan separate cleanup procedures for Entra ID if needed.

Verification: You should see the "Device cleanup rules" page with options to "Create" new rules. The page header should show "Device cleanup rules" and display any existing rules in a table format.

03

Analyze Current Device Inventory

Before creating cleanup rules, analyze your current device inventory to determine appropriate inactivity thresholds. This prevents accidentally hiding devices that are legitimately offline.

Navigate to Devices > All devices to review your device inventory. Use the built-in filters to analyze device activity:

  1. Click the Filter button at the top of the device list
  2. Add filter criteria:
    • Last check-in: Set to "Older than 30 days"
    • Platform: Select specific platforms if needed
    • Compliance state: Review non-compliant devices
  3. Export the filtered results by clicking Export to analyze in Excel

Review the exported data to identify patterns:

  • How many devices haven't checked in for 30, 60, 90+ days?
  • Are there seasonal patterns (vacation periods, remote work)?
  • Which platforms have longer offline periods?
Pro tip: Start with a 60-day threshold as a baseline, then adjust based on your organization's specific patterns. Consider that some devices like conference room tablets or kiosks may have irregular check-in schedules.

Verification: You should have a clear understanding of your device activity patterns and a recommended inactivity threshold. Document the number of devices that would be affected by different threshold values (30, 60, 90, 180 days).

04

Create Your First Device Cleanup Rule

Now create a device cleanup rule with your determined inactivity threshold. Start with a conservative approach for your first rule.

From the Device cleanup rules page, click Create to start the rule creation wizard:

Basic Settings Configuration:

  1. Name: Enter a descriptive name like "Windows Devices - 90 Day Cleanup"
  2. Description: Add details like "Hides Windows devices inactive for 90+ days to maintain clean inventory"
  3. Platform: Select your target platform:
    • Choose All platforms for universal cleanup
    • Select Windows for platform-specific rules (recommended for granular control)
    • Other options: Android (AOSP), Android (fully managed), iOS/iPadOS, macOS

Click Next to proceed to rule settings.

Rule Settings Configuration:

  1. In the "Remove devices that haven't checked in for this many days" field, enter your threshold (between 30-270 days)
  2. For your first rule, use 90 days as a conservative starting point
  3. Click Preview affected devices to see which devices will be hidden by this rule

Review the preview carefully - these devices will be hidden from your Intune console once the rule is active.

Warning: There's no exclusion mechanism for device groups. If you have devices that legitimately stay offline for extended periods, consider a higher threshold or manual management for those specific devices.

Verification: The preview should show a reasonable number of devices. If the number seems too high, increase the threshold. Click "Next" when satisfied with the preview results.

05

Review and Deploy the Cleanup Rule

Complete the rule creation process by reviewing all settings and deploying the rule to your environment.

On the "Review + create" page:

  1. Verify all settings are correct:
    • Rule name and description
    • Target platform
    • Inactivity threshold (days)
    • Estimated affected devices
  2. If everything looks correct, click Create
  3. If you need to make changes, click Previous to go back

After clicking Create, the rule will be active immediately and will run on Microsoft's automated schedule. The system will begin hiding devices that meet the inactivity criteria.

Monitor the rule's impact by returning to Devices > Device cleanup rules. You'll see:

  • Rule status (Active/Inactive)
  • Number of devices currently hidden by the rule
  • Last run timestamp
  • Platform targeting information
Pro tip: Create separate rules for different platforms rather than using "All platforms". This gives you better control and allows platform-specific thresholds based on usage patterns.

Verification: The new rule should appear in your Device cleanup rules list with an "Active" status. Check the "Devices hidden" count after 24 hours to confirm the rule is working. Navigate to Devices > All devices and verify that your total device count has decreased appropriately.

06

Configure Platform-Specific Cleanup Rules

Create additional cleanup rules for different platforms to optimize your device management strategy. Different device types often have different usage patterns requiring tailored approaches.

Return to Devices > Device cleanup rules and click Create for each additional platform:

Recommended Platform-Specific Thresholds:

PlatformRecommended ThresholdReasoning
Windows60-90 daysRegular business use, frequent updates
iOS/iPadOS90-120 daysPersonal devices, vacation periods
Android60-90 daysMix of personal and corporate use
macOS90-120 daysCreative/development workflows, project-based usage

For each platform rule:

  1. Name: Use format "[Platform] - [Threshold] Day Cleanup" (e.g., "iOS Devices - 120 Day Cleanup")
  2. Platform: Select the specific platform
  3. Threshold: Use the recommended values above as starting points
  4. Preview: Always check affected devices before creating

Create rules in this order of priority:

  1. Windows devices (highest volume, most predictable patterns)
  2. Android devices (second highest volume)
  3. iOS/iPadOS devices
  4. macOS devices (if applicable)
Pro tip: Start with higher thresholds (120+ days) for your first month, then gradually reduce them as you understand your environment's patterns. This prevents accidentally hiding devices that are still in use.

Verification: You should have separate cleanup rules for each platform in your environment. Check that each rule shows the expected number of affected devices and that the total doesn't exceed your comfort level for hidden devices.

07

Monitor and Adjust Cleanup Rule Performance

Regularly monitor your cleanup rules to ensure they're working effectively and adjust thresholds based on real-world usage patterns.

Set up a monitoring routine by checking these metrics weekly:

Key Metrics to Track:

  1. Devices hidden per rule: Navigate to Devices > Device cleanup rules
  2. Total device count changes: Compare Devices > All devices counts over time
  3. Device reappearance rate: Track how many hidden devices come back online
  4. Help desk tickets: Monitor for users reporting "missing" devices

Monthly Review Process:

# Use Microsoft Graph PowerShell to export device data for analysis
Connect-MgGraph -Scopes "DeviceManagementManagedDevices.Read.All"

# Get all managed devices with last sync time
$devices = Get-MgDeviceManagementManagedDevice -All | Select-Object DeviceName, Platform, LastSyncDateTime, ComplianceState

# Export for analysis
$devices | Export-Csv -Path "C:\temp\intune-devices-$(Get-Date -Format 'yyyy-MM-dd').csv" -NoTypeInformation

# Analyze devices by platform and last sync
$devices | Group-Object Platform | ForEach-Object {
    $platformDevices = $_.Group
    $staleDevices = $platformDevices | Where-Object { $_.LastSyncDateTime -lt (Get-Date).AddDays(-60) }
    Write-Output "$($_.Name): $($staleDevices.Count) devices older than 60 days"
}

Adjustment Guidelines:

  • Too many devices hidden: Increase threshold by 30 days
  • Too few devices hidden: Decrease threshold by 15 days
  • Frequent reappearances: Consider increasing threshold for that platform
  • User complaints: Review specific device patterns and adjust accordingly
Warning: Hidden devices can reappear if they check in within 180 days and their Intune certificate is still valid. This is normal behavior, not a rule malfunction.

Verification: Run the PowerShell analysis monthly and document trends. Your cleanup rules should maintain a stable "hidden devices" count with minimal user impact. Adjust thresholds if you see consistent patterns of devices being hidden and reappearing frequently.

08

Handle Microsoft Entra ID Device Cleanup

Since Intune cleanup rules only hide devices from the Intune console, implement separate procedures to clean up stale devices from Microsoft Entra ID for complete environment hygiene.

Access the Microsoft Entra admin center at https://entra.microsoft.com and navigate to Identity > Devices > All devices.

Identify Stale Entra ID Devices:

  1. Use the filter options to find inactive devices:
    • Activity: Set to "Inactive for more than 60 days"
    • Join type: Filter by "Azure AD joined" or "Hybrid Azure AD joined"
    • Device state: Look for "Enabled" devices that are actually stale
  2. Export the filtered list for analysis
  3. Cross-reference with your Intune hidden devices list

Cleanup Procedures by Join Type:

For Azure AD Joined Devices:

# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Device.ReadWrite.All"

# Get devices inactive for more than 90 days
$cutoffDate = (Get-Date).AddDays(-90)
$staleDevices = Get-MgDevice -All | Where-Object {
    $_.ApproximateLastSignInDateTime -lt $cutoffDate -and
    $_.TrustType -eq "AzureAd"
}

# Review before deletion
$staleDevices | Select-Object DisplayName, ApproximateLastSignInDateTime, TrustType | Format-Table

# Delete stale devices (uncomment when ready)
# $staleDevices | ForEach-Object { Remove-MgDevice -DeviceId $_.Id }

For Hybrid Azure AD Joined Devices:

  • Delete stale computer objects in on-premises Active Directory
  • Move stale objects to an OU not synced with Azure AD Connect
  • Use Azure AD Connect to sync the deletions to Entra ID

Automated Cleanup Script:

# Weekly cleanup script for Entra ID devices
param(
    [int]$DaysInactive = 90,
    [switch]$WhatIf = $true
)

Connect-MgGraph -Scopes "Device.ReadWrite.All"

$cutoffDate = (Get-Date).AddDays(-$DaysInactive)
$staleDevices = Get-MgDevice -All | Where-Object {
    $_.ApproximateLastSignInDateTime -lt $cutoffDate -and
    $_.TrustType -eq "AzureAd" -and
    $_.AccountEnabled -eq $true
}

Write-Output "Found $($staleDevices.Count) stale devices older than $DaysInactive days"

if ($WhatIf) {
    $staleDevices | Select-Object DisplayName, ApproximateLastSignInDateTime | Format-Table
} else {
    $staleDevices | ForEach-Object {
        Write-Output "Deleting device: $($_.DisplayName)"
        Remove-MgDevice -DeviceId $_.Id
    }
}
Pro tip: Always run cleanup scripts with the -WhatIf parameter first to preview what will be deleted. Schedule Entra ID cleanup to run after your Intune cleanup rules have had time to process.

Verification: After running the cleanup, verify that your Entra ID device count has decreased appropriately. Check that no active devices were accidentally removed by reviewing recent sign-in logs. The total device count in Entra ID should now more closely match your active Intune device count.

Frequently Asked Questions

Do Intune device cleanup rules permanently delete devices from my environment?+
No, device cleanup rules are a soft-delete mechanism that only hides devices from the Intune admin console and reports. The devices remain in Microsoft Entra ID and can reappear in Intune if they check in again with a valid management certificate. To permanently remove devices, you need separate cleanup procedures for Entra ID.
What happens if a hidden device comes back online after being cleaned up?+
If a device was hidden due to inactivity but comes back online within 180 days and still has a valid Intune management certificate, it will automatically reappear in your Intune console. This is expected behavior. Once the certificate expires (typically one year after enrollment), the device would need to be re-enrolled to become visible again.
Can I exclude specific device groups from cleanup rules in Intune?+
No, Microsoft Intune device cleanup rules currently do not support exclusion groups or device-specific exemptions. If you have devices that legitimately stay offline for extended periods, you should set a higher inactivity threshold (180-270 days) or manually manage those specific devices outside of the cleanup rules.
What's the difference between device cleanup rules and device retirement in Intune?+
Device cleanup rules simply hide inactive devices from the console without taking any action on the device itself. Device retirement actively removes company data and unenrolls the device from management. Cleanup rules are reversible if the device comes back online, while retirement requires re-enrollment to restore management.
How often do Intune device cleanup rules run and can I control the schedule?+
Device cleanup rules run automatically on Microsoft's internal schedule, typically daily. You cannot control or modify this schedule. The rules evaluate all devices against your configured inactivity thresholds and hide devices that meet the criteria. Changes to rule settings take effect immediately for the next scheduled run.

Discussion

Share your thoughts and insights

Sign in to join the discussion