How to delete multiple devices at once on Intune
In Microsoft Intune, you can delete multiple devices by creating and applying a device cleanup policy or by removing devices manually using the Intune admin console. Here are two methods to delete multiple devices in Intune:
Method 1: Using Device Cleanup Policy (Recommended)
Create a Device Cleanup Policy:
- Sign in to the Microsoft 365 Device Management portal (https://devicemanagement.microsoft.com/).
- Go to "Devices" > "Device cleanup policies."
- Click on "Create policy."
- Configure the policy settings, such as the number of days a device should be inactive before deletion and whether to notify users before deletion. You can also choose to exclude specific device groups.
- Save the policy.
Assign the Policy:
- After creating the policy, assign it to the desired group of devices or users. This will determine which devices will be subject to the cleanup policy.
Monitor and Verify:
- Over time, Intune will automatically evaluate the devices based on the policy criteria and delete devices that meet the criteria. You can monitor the cleanup progress and review the devices that were deleted in the Intune admin console.
Method 2: Manual Deletion of Devices
Sign in to the Intune Admin Console:
- Go to the Microsoft 365 Device Management portal (https://devicemanagement.microsoft.com/).
Navigate to Devices:
- In the left-hand menu, click on "Devices."
Select Devices to Delete:
- Use filters, search, or device groups to locate the devices you want to delete.
Select Multiple Devices:
- You can select multiple devices by checking the boxes next to their names.
Delete Devices:
- Once the devices are selected, click on the "Delete" button in the top menu.
Confirm Deletion:
- You will be prompted to confirm the deletion of the selected devices. Confirm the deletion.
Monitor and Verify:
- Keep an eye on the device deletion process and verify that the selected devices have been deleted.
Please exercise caution when deleting devices manually, as this action is irreversible. Make sure you are certain about the devices you want to remove from Intune. Using the Device Cleanup Policy is a safer way to automate the deletion of inactive devices while minimizing the risk of accidental deletion.
You can use PowerShell and the Microsoft Graph API to delete multiple devices in Microsoft Intune. Here's a step-by-step guide on how to do it:
Note: Before proceeding, make sure you have the required permissions and have set up the necessary authentication for accessing the Microsoft Graph API using PowerShell.
Install Required Modules: If you haven't already, install the required PowerShell modules:
powershellInstall-Module -Name PowerShellGet -Force -AllowClobber Install-Module -Name AzureAD -Force -AllowClobber Install-Module -Name MSAL.PS -Force -AllowClobber
Connect to Microsoft Graph: Run the following commands to connect to the Microsoft Graph API using PowerShell. You will need to sign in with your admin account:
powershellConnect-AzureAD $graphAppId = "YOUR_APP_ID" # Replace with your Azure AD app registration's Application ID $graphAppSecret = "YOUR_APP_SECRET" # Replace with your Azure AD app registration's Client Secret $tenantId = "YOUR_TENANT_ID" # Replace with your Azure AD tenant ID $token = Get-MsalToken -ClientId $graphAppId -ClientSecret $graphAppSecret -TenantId $tenantId -Scopes "https://graph.microsoft.com/.default"
Delete Devices: You can use the Microsoft Graph API to delete devices. Below is an example of how to delete multiple devices using PowerShell:
powershell$deviceIdsToDelete = @("deviceID1", "deviceID2", "deviceID3") # Replace with the actual Device IDs you want to delete foreach ($deviceId in $deviceIdsToDelete) { $url = "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/$deviceId" $headers = @{ 'Authorization' = "Bearer $($token.AccessToken)" } # Send a DELETE request to delete the device Invoke-RestMethod -Uri $url -Method Delete -Headers $headers }
Replace
"deviceID1"
,"deviceID2"
, etc., with the actual Device IDs you want to delete. This script will loop through the list of Device IDs and send a DELETE request to the Microsoft Graph API to delete each device.Verify Deletion: You can verify that the devices have been deleted by checking the Microsoft Intune admin console or by running queries against the Microsoft Graph API to confirm that the devices are no longer listed.
Please ensure that you have the necessary permissions and take precautions when running scripts that delete devices, as this action is irreversible. Always test in a controlled environment before executing scripts in a production environment.
Comments
Post a Comment