Retrieves activity logs for Azure resources.
Get-AzLog
    [-ResourceId <String>]
    [-ResourceGroup <String>]
    [-ProviderName <String>]
    [-Status <String>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-OperationName <String>]
    [-CorrelationId <String>]
    [-MaxRecordCount <Int32>]
    [-DefaultProfile <IAzureContextContainer>]The Get-AzLog cmdlet retrieves the activity logs for Azure resources. Activity logs provide insights into operations performed on your Azure resources, including monitoring, troubleshooting, and auditing.
The ID of the resource for which to retrieve activity logs. This is typically in the format `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}`.
The name of the resource group for which to retrieve activity logs.
The name of the resource provider (e.g., Microsoft.Compute) for which to retrieve activity logs.
Filters the logs by status (e.g., Started, Succeeded, Failed).
Specifies the start time for the log query. Logs generated at or after this time will be returned.
Specifies the end time for the log query. Logs generated before this time will be returned.
Filters the logs by operation name (e.g., Microsoft.Compute/virtualMachines/read).
Filters the logs by a correlation ID, which can help trace related operations.
The maximum number of log records to return.
The credentials, account, tenant, and subscription used for communication with Azure.
This example retrieves all activity logs for the current subscription within the last 24 hours.
Get-AzLog -StartTime (Get-Date).AddDays(-1)This example retrieves activity logs for the resource group named "MyResourceGroup" within the last 7 days.
Get-AzLog -ResourceGroup "MyResourceGroup" -StartTime (Get-Date).AddDays(-7)This example retrieves activity logs for a virtual machine named "MyVM" in the "MyResourceGroup" resource group.
$resourceId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM"
Get-AzLog -ResourceId $resourceId -StartTime (Get-Date).AddHours(-2)This example retrieves activity logs that resulted in a "Failed" status within the last day.
Get-AzLog -Status "Failed" -StartTime (Get-Date).AddDays(-1)