Home > Back-end >  Powershell: Display a System.Object in Query Results
Powershell: Display a System.Object in Query Results

Time:12-01

having trouble including certain results in a query for AzureADSignInLogs.

I have the following statement, but would like to include more results that are System.Objects.

Get-AzureADAuditSignInLogs |
    Where-Object{$_.ClientAppUsed -like 'Exchange ActiveSync'} |
    Format-Table CreatedDateTime, UserPrincipalName, AppDisplayName, ClientAppUsed

On the end, i'd like to include an ErrorCode which falls under the Status parent:

SCREENSHOT: Powershell Results of Get-AzureADSignInLogs

But I'm not sure how to drill down to fetch the information then display it. Is it possible in a Format-Table? Or does there have to be some other way?

CodePudding user response:

You would handle the data before using Format-Table as this changes the structure of the data from an object perspective.

Please see the below where I have used a calculated property on a select-object statement.

Get-AzureADAuditSignInLogs |
    Where-Object{$_.ClientAppUsed -like 'Exchange ActiveSync'} |
    Select-Object CreatedDateTime, UserPrincipalName, AppDisplayName, ClientAppUsed, @{Name = "ErrorCode"; Expression = {$_.Status.ErrorCode}} |
    Format-Table

As I do not have a premium license I am unable to test the above in Azure.

  • Related