Dear,
I am in need of a list of all users in my Microsoft Azure account and next to them a column with their last longondate as I want clean up old non-active users.
I already have a script for extracting users and associate groups:
Get-AzureADUser -All $true | select UserPrincipalName, @{n="Groups";e={(Get-AzureADUserMembership -ObjectId $.ObjectId -All $true | ? {$.ObjectType -eq "Group" -and $.SecurityEnabled -eq $true -and $.MailEnabled -eq $false } | select -ExpandProperty DisplayName) -join "," }} | Export-Csv 'output.csv'
But now I also need a script to find the last activity dates of these users. Do you know whether there is some command I can add to the script above to also have an additional column with the last log-on date? And if not do you have a script that I could use to extract all users and their last logon date? (I have been looking into the "Get-AzureADAuditSignInLogs" API but unfortunately I keep stumbling into syntax errors or cmlet errors).
Thank you already.