Remove Stale Intune Devices Automatically

This script will automatically remove stale intune devices for you based on a configurable number of days the device was not active.Note that the script uses a beta / unsupported Intune Graph API endpoint and method to retrieve a token.You need to create a Credential Object in yo

 
 
 
 
 
(0)
573 times
Add to favorites
Windows Azure
4/11/2018
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Token error
    2 Posts | Last post July 11, 2018
    • Hi Jos - Thanks for the script.  I am having a problem - Failed to retrieve access token from Azure.  I am using a service account that is licensed for Intune.
      
      Any ideas?  Thanks in advance.
      
      Failed
      The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: access token is null!
      Retrieving runbook credential object
      Credentials retrieved
      Get-AuthToken : Failed to retrieve access token from Azure
      At line:254 char:21
      + ... authToken = Get-AuthToken -User $intuneAdminCreds.UserName -Password  ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-AuthToken
       
    • Hi Kevin,
      
      Rather than fixing, I'd recommend switching to Intune's new native option for this: https://osddeployment.dk/2018/07/08/automatic-device-cleanup-in-intune/