Tutorial: How to download and use a script to access sign-in logs

You can download the sign-in activities data if you want work with it outside the Azure portal. The Download option in the Azure portal creates a CSV file of the most recent 5000 records. If you need more flexibility, for instance, to download more than 5000 records at a time, or to download the logs at scheduled intervals, you can use the Script button to generate a PowerShell script to download your data.

In this tutorial, you learn how to generate a script to download all the sign-in logs from the last 24 hours and schedule it to run every day.


You need

  • An Azure Active Directory tenant with a premium (P1/P2) license. Note that if you did not have any activities data prior to the upgrade, it will take a couple of days for the data to show up in the reports after you upgrade to a premium license.
  • A user, who is in the global administrator, security administrator, security reader or report reader role for the tenant. In addition, any user can access their own sign-ins.
  • If you want to run the downloaded script on your Windows 10 machine, set up the Azure PowerShell module and set execution policy.


  1. Navigate to the Azure portal and select your directory.
  2. Select Azure Active Directory and select Sign-ins from the Monitoring section.
  3. Use the Date Range filter drop-down and select 24 Hours to get data from the last 24 hours.
  4. Select Apply and verify that the filter is applied as expected.
  5. Select Script from the top menu to download the Powershell script with the applied filters.

    Download script

  6. Open the Task Scheduler application on your Windows machine and select Create Basic Task.

  7. Enter a name and description for the task and click Next.
  8. Select the Daily radio button to allow the task to run daily and enter the start date and time.
  9. In the action menu, select Start a program and select the downloaded script and select Next.
  10. Review the scheduled task and select Finish to create the task.

    Create task

Now, your task will run every day and save the sign-in records from the last 24 hours into a file of the format AAD_SignInReport_YYYYMMDD_HHMMSS.csv. You can also edit the downloaded PowerShell script to save it under a different file name, or to modify the number of records downloaded.

Next steps