Exporting user last login to M365 or Azure to .CSV file ?

EnterpriseArchitect 6,041 Reputation points
2022-10-10T13:43:24.61+00:00

How can I extract and export the last user login time to the M365 portal or Azure AD as .CSV file?

is there any PowerShell script or GUI procedure?

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. Olga Os - MSFT 5,951 Reputation points Microsoft Employee
    2022-10-10T17:13:43.287+00:00

    Hello @EnterpriseArchitect ,

    Welcome to the MS Q&A Forum.

    In the past, I used these steps to collect the last login date and export to .csv:

    • Go to the Azure portal => App registrations => Register a Test APP
    • Create a secret and save the value
      249020-image.png
    • Go to API permissions, select Microsoft Graph Explorer and finally select the below permissions

    249040-image.png

    • Make sure to add those permissions and Grant the Admin consent for the tenant.
    • Once this is done you need to modify the requested parameters on the script and run it.

    Run PowerShell script https://github.com/12Knocksinna/Office365itpros/blob/master/GetUserSignInDataGraph.PS1 where you will use parameters from above steps.

    Output example:

    249047-image.png

    Hope above answers your questions and concerns.

    --------------------------------------------------------

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.

    Sincerely,
    Olga Os

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. KRANTI KUMAR DANALAKOTA 6 Reputation points
    2023-01-06T19:29:06.23+00:00

    276957-image.png

    1 person found this answer helpful.

  2. Donald Flowers 5 Reputation points
    2023-02-15T20:01:48.8033333+00:00

    @Graham C @Gal Shalom You just have to ensure to change the following lines for it to work.

    $AppId = "d716b32c-0edb-48be-9385-30a9cfd96155"

    $TenantId = "c662313f-14fc-43a2-9a7a-d2e27f4f3478"

    $AppSecret = 's_rkvIn1oZ1cNceUBvJ2or1lrrIsb*:='

    It worked fine after that :)

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.