Im fairly new to powershell, and i’m trying to run a simple script which should provice me with the last logon from guest users in our Azure AD.<\/p>\n
Get-AzureADUser -All $true -filter \"usertype eq 'guest'\" | Select UserPrincipalName, DisplayName, LastLogonDate | Export-CSV c:\\lastloginguest.csv\n<\/code><\/pre>\n
Advertisement
Im getting the UPN and Displayname as requested, but it doens’t show the lastlogonDate (or lastloginTime etc etc).<\/p>\n
Advertisement
What am i doing wrong here?<\/p>","upvoteCount":8,"answerCount":4,"datePublished":"2023-04-05T05:33:43.000Z","author":{"@type":"Person","name":"spiceuser-c7bie","url":"https://community.spiceworks.com/u/spiceuser-c7bie"},"suggestedAnswer":[{"@type":"Answer","text":"
Im fairly new to powershell, and i’m trying to run a simple script which should provice me with the last logon from guest users in our Azure AD.<\/p>\n
Get-AzureADUser -All $true -filter \"usertype eq 'guest'\" | Select UserPrincipalName, DisplayName, LastLogonDate | Export-CSV c:\\lastloginguest.csv\n<\/code><\/pre>\nIm getting the UPN and Displayname as requested, but it doens’t show the lastlogonDate (or lastloginTime etc etc).<\/p>\n
What am i doing wrong here?<\/p>","upvoteCount":8,"datePublished":"2023-04-05T05:33:43.000Z","url":"https://community.spiceworks.com/t/last-logon-guest-users-azure/949527/1","author":{"@type":"Person","name":"spiceuser-c7bie","url":"https://community.spiceworks.com/u/spiceuser-c7bie"}},{"@type":"Answer","text":"
You can try this:<\/p>\n
Get-AzureADUser -All $true -filter \"usertype eq 'guest'\" | select UserPrincipalName,DisplayName,RefreshTokensValidFromDateTime | Export-CSV c:\\lastloginguest.csv\n<\/code><\/pre>\nIts not exactly the last logon but very close to ist 
\nUser profile attributes in Azure Active Directory B2C | Microsoft Learn<\/a><\/p>","upvoteCount":0,"datePublished":"2023-04-05T09:45:39.000Z","url":"https://community.spiceworks.com/t/last-logon-guest-users-azure/949527/2","author":{"@type":"Person","name":"robertrasp","url":"https://community.spiceworks.com/u/robertrasp"}},{"@type":"Answer","text":"