Paul Contreras

Hi, my name is Paul and I am a Sysadmin who enjoys working on various technologies from Microsoft, VMWare, Cisco and many others. Join me as I document my trials and tribulations of the daily grind of System Administration.

8 Comments

  1. I wrote a similar thing but we are at the mercy of the MS servers for responding to queries. A query for 100 users has so far taken over 2 hours to run. An on-prem query for 100 users finishes in about 3 seconds.

  2. Thank you for include John Snow, Tony Stark, and Buzz Lightyear. This working for me.

  3. Sadly this will not work if you don’t have a P1 / 2 Azure AD license:

    Get-AzureADAuditSignInLogs : Error occurred while executing GetAuditSignInLogs
    Code: Authentication_RequestFromNonPremiumTenantOrB2CTenant
    Message: Neither tenant is B2C or tenant doesn’t have premium license

  4. Hi, great article!
    I am a bit of newbie in this but I am trying to build a script that gives me the login status for a series of users.

    I have tried this, but with no visible results:

    #Import the Azure AD Module
    Import-Module AzureADPreview

    #Connect to Azure AD
    Connect-AzureAD -AccountId [email protected]

    $CSVData = @(Import-CSV -Path AzureADBulkUserCreation.csv -ErrorAction Stop)
    Write-Verbose “Successfully imported entries from $FilePath”
    Write-Verbose “Total no. of entries in CSV are : $($CSVData.count)”

    Foreach ($Entry in $CSVData) {
    # Verify that mandatory properties are defined for each object
    $UserPrincipalName = $Entry.UserPrincipalName
    }

    foreach ($UserPrincipalName in $CSVData) {
    Get-AzureADAuditSignInLogs -Filter “UserPrincipalName eq ‘$UserPrincipalName'” -Top 1 | `
    select CreatedDateTime, UserPrincipalName, IsInteractive, AppDisplayName, IpAddress, TokenIssuerType, @{Name = ‘DeviceOS’; Expression = {$_.DeviceDetail.OperatingSystem}}
    }

    Any idea of what could be going wrong?

    • Please check if the users in the CSV file have any Sign in logs available in the last 30 days.
      I had the similar issue and realized that there were no Sign in logs for the users I tried in the last 30 days.

Leave a Reply

Your email address will not be published.