Get-AzSubscriptionActivityLog
Gets Activity Log events from an Azure subscription with filtering options.
Syntax
Description
Get-AzSubscriptionActivityLog retrieves events from the Activity Log in an Azure subscription using the REST API. Caller identities are translated to their friendly names from their GUIDs. Requires the Az.Accounts module for authentication in the current context.
Note by default, operations with 'List' or 'Get token' in the name are excluded from the results as these can be numerous. To include them, use the -IncludeListAndGetOperations parameter
Permissions
Requires at least a Reader role in the Azure subscription.
Requires Directory.Read.All permission in Microsoft Graph.
Install
Install the script from the PowerShell gallery:
Connect to Azure
if you haven't already authenticated to Azure, run the Connect-AzAccount cmdlet first, eg
Examples
Example 1 - Get activity log events for the last 12 hours
This command gets activity logs from the specified tenant and subscription over the last 12 hours.
Example 2 - Get activity log events for a specific identity type
This command gets events where the caller type is a managed identity.
Example 3 - Get activity log events for specific categories
This command gets events with a category of Policy or Security.
Example 4 - Get activity log events for specific callers
This command gets events where the calling identity is either Windows 365 or Microsoft.RecoveryServices. You could also specify the displayname of a managed identity or the UPN of a AAD user.
Example 5 - Get activity log events with a specific severity
This command gets events with a severity level of either Error or Warning.
Example 6 - Get activity log events for specific resource groups
This command gets events from the resource groups rg-01 and rg-02.
Example 7 - Get activity log events for specific resource providers
This command gets events where the resource provider is either Microsoft.Network or Microsoft.VirtualMachineImages
Example 8 - Get activity log events for a specific resource
This command gets events where the resourceId matches the string VM001, which in this case is a virtual machine name. This could be any part of the resourceId name after the resource provider and supports a single string only.
Example 9 - Get activity log events for a specific resource type
This command gets events where the resource type is either MICROSOFT.RECOVERYSERVICES/vaults or Microsoft.Compute/virtualMachines
Example 10 - Get activity log events for specific operations
This command gets events where the operation name is either Start Virtual Machine or Backup Protected Item
Example 11 - Get activity log events with a specific status
This command gets events with a status of Failed or Accepted.
Example 12 - Get activity log events including List and Get token operations
This command gets all events including any List or Get token operations, which are excluded by default as they can be numerous.
Example 13 - Get activity logs including additional properties
This command gets events and includes any additional properties that are attached to the event.
Example 14 - View the additional properties for an event
This command retrieves the additional properties for the first event in the array, formatted as a list.
Example 15 - Group and count events by Operation
This command groups events by their operationName and displays the counts of each operation with the most numerous first
Example 16 - Group and count events by category
This command groups events by their category and displays the counts of each category with the most numerous first.
Parameters
Last updated