Try Microsoft Graph PowerShell
# Install the Microsoft Graph PowerShell module if needed
Install-Module Microsoft.Graph -Scope CurrentUser
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "AuditLog.Read.All", "User.Read.All"
# Get the current date minus 90 days
$ThresholdDate = (Get-Date).AddDays(-90).ToString("yyyy-MM-dd")
# Fetch users who haven't signed in within the last 90 days
Get-MgUser -Filter "signInActivity/lastSignInDateTime lt $ThresholdDate" -Property id, displayName, signInActivity |
Select-Object displayName, signInActivity
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin