Forum Discussion
Microsoft Graph Sign in Log Script
- Dec 16, 2024
Hi Zac,
you can display the location with the other properties by adding it as an expression. You call the respective property with Location.<property>. This works with all properties where the value is an object, i.e. starts with Microsoft.Graph.PowerShell.Models.
Example:
Get-MgAuditLogSignIn | Select-Object -First 1 -Property CreatedDateTime, AppDisplayName, ClientAppUsed, IPAddress, @{Name=“City”;Expression={$_.Location.City}}, @{Name=“Country/Region”;Expression={$_. Location.CountryOrRegion}}, @{Name=“State”;Expression={$_.Location.State}}, @{Name=“ErrorCode”;Expression={$_.Status.ErrorCode}}, @{Name=“FailureReason”;Expression={$_.Status.FailureReason}}To know which properties exist for an object, you can display the members of the object as follows:
$signIn = Get-MgAuditLogSignIn | Select-Object -First 1
$signIn.Location | Get-MemberAmong other things, the properties with the MemberType property are displayed here.
I hope this is what you meant.
Hi Zac,
you can display the location with the other properties by adding it as an expression. You call the respective property with Location.<property>. This works with all properties where the value is an object, i.e. starts with Microsoft.Graph.PowerShell.Models.
Example:
Get-MgAuditLogSignIn | Select-Object -First 1 -Property CreatedDateTime, AppDisplayName, ClientAppUsed, IPAddress, @{Name=“City”;Expression={$_.Location.City}}, @{Name=“Country/Region”;Expression={$_. Location.CountryOrRegion}}, @{Name=“State”;Expression={$_.Location.State}}, @{Name=“ErrorCode”;Expression={$_.Status.ErrorCode}}, @{Name=“FailureReason”;Expression={$_.Status.FailureReason}}
To know which properties exist for an object, you can display the members of the object as follows:
$signIn = Get-MgAuditLogSignIn | Select-Object -First 1
$signIn.Location | Get-Member
Among other things, the properties with the MemberType property are displayed here.
I hope this is what you meant.