PowerShell to get any successful Azure object deployment or creation in the past 24 hours

EnterpriseArchitect 6,166 Reputation points
2025-08-22T07:48:59.2733333+00:00

How can I get these results sent to me daily via email?

# Make sure the Az module is installed & imported
# Install-Module Az -Scope CurrentUser
Connect-AzAccount
# Define time range
$startTime = (Get-Date).AddDays(-1)
$endTime   = Get-Date
# Query the activity log
Get-AzActivityLog -StartTime $startTime -EndTime $endTime -Status Succeeded -WarningAction SilentlyContinue |
    Where-Object {
        # OperationName usually contains verbs like 'write', 'create', 'deploy'
        $_.OperationName.Value -match 'write|create|deploy'
    } |
    Select-Object `
        EventTimestamp,
        ResourceGroupName,
        ResourceId,
        @{Name='Operation';Expression={$_.OperationName.LocalizedValue}},
        Caller,
        Status |
    Sort-Object EventTimestamp -Descending

using Azure Automation?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.