title: How can i get the lastlogon users in Azure AD?
body: <p>I would like to output the list of users who have not logged in for more than a month to retrieve licenses. How can I obtain the last connection of users who have an AD license whose accounts are still active.</p>
  <pre><code>$guestuserIDs= (Get-AzureADUser -Filter &quot;AccountEnabled eq true&quot; | Select-Object ObjectId).ObjectId
  
  $startTime = (get-date).AddDays(-30).ToString(&quot;yyyy-MM-dd&quot;)
  
  foreach($guestUserID in $guestuserIDs){
      Get-AzureADAuditSignInLogs -Filter &quot;UserId eq '$guestUserID'&quot; -Top 1 |Select-Object UserId,UserDisplayName,CreatedDateTime 
  }
  </code></pre>
  <p>I don't know how and if it's possible to add a command line to validate users who are currently consuming a license. Any help would be appreciate! Thanks</p>