Solved, had a typo in the loop that returned the same date
instead of
$AllUsers.SignInActivity.LastSignInDateTime
I should have used $_.SignInActivity.LastSignInDateTime this works and returns the correct date
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I am trying to load the users Last sign-in date/times as these are displayed in Azure AD, for example:
And trying to get this with microsofr.graph Get-MgUser.
I am loading the SignInActivity.LastSignInDateTime but the value returned is not matching the date that I see for this user on Azure AD as the attached image. Is there another attribute that I should check instead?
I am rather new with powershell so I would appreciate any ideas.
Get-MgUser -All
$Properties = @(
'Mail', 'AccountEnabled', 'SignInActivity'
)
#Get All users along with the properties
$AllUsers = Get-MgUser -All -Property $Properties
Write-Output $AllUsers
# Perform Search
$AllUsers | ForEach-Object {
$LastLoginDate = $AllUsers.SignInActivity.LastSignInDateTime
$_ |add-Member -MemberType Noteproperty -Name LastLoginDate -Value $LastLoginDate
}
#From $users displays only alias and LastLogonTime properties
$AllUsers | ft DisplayName,LastLoginDate
Solved, had a typo in the loop that returned the same date
instead of
$AllUsers.SignInActivity.LastSignInDateTime
I should have used $_.SignInActivity.LastSignInDateTime this works and returns the correct date
Solved, had a typo in the loop that returned the same date
instead of
SQL
$AllUsers.SignInActivity.LastSignInDateTime
I should have used $_.SignInActivity.LastSignInDateTime this works and returns the correct da