Script to Remove Stale Intune Devices

PowerShell script that uses Graph API to connect to Intune and retire/delete stale devices that have not checked in to the service within the past 90 days. Corresponding blog post on how to automate the retire and deletion of devices can be found here: https://blogs.technet.mic

3.8 Star
2,209 times
Add to favorites
E-mail Twitter Digg Facebook
  • Problem with execution script...
    3 Posts | Last post November 05, 2018
    • I'm trying to execute script from powershell, and with appropriate credentials on Intune, but I stuck on: PS C:\Temp> & '.\Remove-StaleIntuneDevices2.ps1'
      Checking for AzureAD module...
      Authorization Access Token is null, please re-run authentication...
    • Try: Get-AuthToken
    • Hi Dule.bgd,
      I had the same issue, is the tenant using MFA? MFA is known to cause issues when Authenticating. I solved my problem by using a Service account with no MFA enabled.
      get-authtoken is where it fails @Nielsvd
  • Error message
    2 Posts | Last post May 16, 2018
    • I'm trying to use this script with AzureADPreview module installed. I'm getting these messages:
      Checking for AzureAD module...
      AzureAD PowerShell module not found, looking for AzureADPreview
      Input string was not in a correct format.
      Not sure what input string is incorrect.
    • Disregard. I missed a step in the blog.