Hi ,
as you said you tried with multiples command and its failed, this might be due to a known a issue (if you were getting error : The term 'Get-AzureADAuditSignInLogs' is not recognized as the name of a cmdlet go with step 1 first ) ,make sure to unload the AzureAD module, then load the AzureADPreview one , then go with step 2, sample command .
1st step
Remove-module azuread
Install-Module AzureADPreview -AllowClobber -Force
similar problem - https://learn.microsoft.com/en-us/answers/questions/772918/index.html
Step 2
Import-Module AzureADPreview
$Cred = Get-Credential
Connect-MsolService -Credential $Cred
Connect-AzureAD -Credential $Cred
$Users = Get-MsolUser -all
$Headers = "DisplayNametUserPrincipalName
tLicensetLastLogon" >>C:\Mylist.csv ForEach ($User in $Users) { $UPN = $User.UserPrincipalName $LoginTime = Get-AzureAdAuditSigninLogs -top 100 -filter "userprincipalname eq '$UPN'" | select CreatedDateTime $NewLine = $User.DisplayName + "
t" + $User.UserPrincipalName + "`t" + $LoginTime.CreatedDateTime
$NewLine >>'C:\Mylist.csv'
}
You can change the name based on your CSV file and header title . if you got any error ,kindly share the screenshot of the error .
Hope this will work, please let me know if you have any question .
Thanks