Skip to main content
VM Lifecycle Management

Azure VM DeallocationAnalysis Tool

Professional PowerShell script that identifies deallocated Azure VMs for lifecycle management. Track VM aging, ownership, and generate detailed CSV + HTML reports for better resource management.

Quick Start
# Basic analysis (30+ days)
.\Detect-DeallocatedVMs.ps1
# Custom threshold (60+ days)
.\Detect-DeallocatedVMs.ps1 -DaysThreshold 60
# Fast mode for large environments
.\Detect-DeallocatedVMs.ps1 -FastMode
Blaze
Blaze says:Deallocated VMs don't cost compute -- but their disks sure do. A VM sitting deallocated for 90 days with 500GB of managed disks is quietly burning through your budget. Start with a 60-day threshold to catch the obvious offenders first.

Standard run path

Structured quick-reference sections for prerequisites, installation, usage, and troubleshooting.

Prerequisites

  • PowerShell 5.1+ or PowerShell Core with Az.Accounts, Az.Resources, Az.ResourceGraph, Az.Compute, and Az.Monitor modules
  • Azure authentication (`Connect-AzAccount`) with Reader access to subscriptions and Monitor Reader access for Activity Logs
  • Local execution environment with permission to write CSV/HTML reports to the chosen output path

Start conservative

Use a higher day threshold (for example 60+) on the first run to focus on obvious cleanup candidates and validate the report data before expanding the scope.

Key parameters

ParameterPurposeTypical use
-DaysThresholdMinimum deallocated days before inclusion (default 30)Use 60-90 days for conservative first pass
-SubscriptionIdsLimits analysis to specific subscriptionsTargeted review for one BU / environment
-OutputPathSets directory for CSV + HTML reportsStore results in shared audit folder
-FastModeSkips detailed Activity Log lookup for speedLarge estates or quick triage runs

Standard run path

  1. 1Run a baseline scan with the default threshold to understand the volume of deallocated VMs.
  2. 2Re-run with `-DaysThreshold 60` (or higher) to narrow the list to more likely cleanup candidates.
  3. 3Use `-FastMode` for large environments, then follow up with detailed scans on the highest-cost subscriptions.
  4. 4Review owner tags and storage footprint before deleting disks or decommissioning resources.
PowerShell
.\\Detect-DeallocatedVMs.ps1
PowerShell
.\\Detect-DeallocatedVMs.ps1 -DaysThreshold 60 -SubscriptionIds @("sub1","sub2")
PowerShell
.\\Detect-DeallocatedVMs.ps1 -FastMode -OutputPath "C:\\Reports\\VM-Deallocation"

Outputs and sample results

CSV + HTML report set

The tool produces a CSV for analysis and an HTML summary for sharing with stakeholders.

FieldExampleWhy it matters
VM Namedev-api-vm-03Identifies the deallocated resource
Deallocated Since2025-09-14Supports aging/cleanup thresholds
Est. Monthly Cost$142.50Prioritizes highest savings opportunities
Owneruntagged / j.smithDrives outreach before cleanup
  • Use the CSV for sorting and prioritization, then use the HTML report in review meetings.

Troubleshooting

  • If deallocation dates are missing, confirm Monitor Reader access and test a smaller scope without `-FastMode`.
  • If output files are not generated, set an explicit `-OutputPath` and verify local write permissions.
  • If the run is slow across many subscriptions, use `-SubscriptionIds` to split analysis into batches.

Professional VM Lifecycle Management

Comprehensive analysis and reporting for deallocated Azure VMs with enterprise-grade features

KQL-Powered Discovery

Uses Azure Resource Graph KQL queries for fast, accurate discovery of deallocated VMs across all subscriptions

Intelligent Aging Analysis

Tracks deallocation dates via Activity Logs with smart estimates for VMs without historical data

Owner Detection

Automatically identifies VM owners through tag analysis including IDSApplicationOwner-Symphony patterns

Dual Report Formats

Generates both CSV (for analysis) and HTML (for executive reporting) with comprehensive VM details

Disk Analysis

Analyzes OS and data disk configurations with size estimates for complete storage impact assessment

Performance Modes

Fast Mode for quick scans or Detailed Mode for comprehensive Activity Log analysis

Enterprise Security

Respects Azure RBAC permissions and includes comprehensive error handling for production environments

Real-time Progress

Chef-themed console output with progress tracking and colorful status indicators for engaging analysis

Usage Examples

Real-world scenarios for VM lifecycle management and optimization

Basic Lifecycle Analysis

.\Detect-DeallocatedVMs.ps1

Identifies VMs deallocated for 30+ days across all accessible subscriptions with detailed aging analysis and owner detection.

Custom Threshold Analysis

.\Detect-DeallocatedVMs.ps1 -DaysThreshold 60

Focuses on VMs deallocated for 60+ days for more conservative lifecycle management and cleanup decisions.

High-Performance Scanning

.\Detect-DeallocatedVMs.ps1 -FastMode

Optimized for large environments, skips detailed Activity Log analysis and uses intelligent estimates for faster execution.

Targeted Subscription Analysis

.\Detect-DeallocatedVMs.ps1 -SubscriptionIds @("sub1","sub2")

Focuses analysis on specific subscriptions for targeted lifecycle management and compliance reporting.

Technical Specifications

Enterprise-grade PowerShell script with comprehensive VM lifecycle analysis capabilities

Requirements

PowerShell 5.1+

Windows PowerShell or PowerShell Core for cross-platform execution

Azure PowerShell Modules

Az.Accounts, Az.Resources, Az.ResourceGraph, Az.Compute, Az.Monitor

Azure Authentication

Interactive login or service principal with appropriate RBAC permissions

RBAC Permissions

Reader access to subscriptions, Monitor Reader for Activity Logs

Execution Environment

Local machine execution (no Azure Automation Account required)

Key Parameters

-DaysThreshold

Minimum days deallocated before inclusion (default: 30)

-SubscriptionIds

Array of specific subscription IDs to analyze

-OutputPath

Directory for CSV and HTML report output

-FastMode

Skip detailed Activity Log analysis for performance

Analysis Features

VM Discovery Engine

  • • KQL-powered Azure Resource Graph queries
  • • Multi-subscription parallel processing
  • • Automatic VM state validation
  • • Hardware profile and OS type detection

Aging Analysis

  • • Activity Log deallocation date tracking
  • • REST API optimization for recent events
  • • Intelligent estimates for historical VMs
  • • Configurable aging thresholds

Ownership Detection

  • • IDSApplicationOwner-Symphony tag priority
  • • Multiple owner tag pattern matching
  • • Case-insensitive tag key searches
  • • Fallback to common ownership patterns

Storage Analysis

  • • OS and data disk size calculation
  • • VM size-based storage estimates
  • • Disk configuration breakdown
  • • Total storage impact assessment

Report Outputs

Comprehensive reporting in multiple formats for different stakeholders

CSV Analysis Report

Detailed CSV export optimized for data analysis, filtering, and integration with business intelligence tools.

VM details and configuration
Aging analysis and deallocation dates
Owner information and contact details
Storage analysis and cost implications
Subscription and resource group organization

HTML Executive Report

Professional HTML report with visual summaries, charts, and executive-friendly presentation for stakeholder communication.

Executive summary and key metrics
Visual charts and aging distribution
Subscription-level breakdown
Recommendations and next steps
Professional formatting for presentations

Chef's Tips & Best Practices

Professional recommendations for effective VM lifecycle management

Start Conservative

Begin with 60+ day thresholds for initial analysis. Like testing a new recipe with small portions, validate your VM lifecycle policies before implementing aggressive cleanup schedules.

Owner Engagement

Use the owner detection to reach out before cleanup. The script identifies owners through tags, enabling proactive communication about VM lifecycle decisions.

Performance Optimization

Use Fast Mode for large environments (1000+ VMs) to get quick insights. Switch to detailed mode for smaller scopes when precise deallocation dates are critical.

Security Considerations

Ensure proper RBAC permissions before analysis. The script respects Azure security boundaries and will only analyze resources you have access to view.

Regular Monitoring

Schedule monthly analysis to track VM lifecycle trends. Regular monitoring helps identify patterns and optimize your VM management policies over time.

Data Integration

Import CSV reports into Power BI or Excel for advanced analytics. The structured output enables trend analysis and executive dashboards for VM lifecycle management.

Ready to Optimize Your VM Lifecycle?

Download the Azure VM Deallocation Analysis Tool and start identifying optimization opportunities in your Azure environment today. Professional VM lifecycle management made simple.

Sample Output

VM NameResource GroupDeallocated SinceEst. Monthly CostOwner
dev-api-vm-03rg-development2025-09-14$142.50untagged
test-db-vm-01rg-testing2025-07-22$287.00j.smith
staging-web-02rg-staging2025-11-01$98.30devops-team

47 deallocated VMs found · Estimated recoverable spend: $3,420/month

What to do next

Pick the path that fits where you are right now.

Trust & run-safety metadata

Key execution details for Azure VM Deallocation Detective so users know what they are downloading or running before they act.

Need verification guidance? See Security & Trust and Responsible Disclosure.

Read-only / reportingGitHub sourceExplicit + inferred metadata

Maintainer

CloudCostChefs

Last Updated

July 4, 2025

Last Tested

February 23, 2026

Minimum Access

Reader access to target Azure subscriptions with VM, Resource Graph, and monitoring metadata visibility

Execution Type

GitHub-hosted PowerShell reporting script (Azure VM deallocation analysis)

Version

2025-07-04

SHA256 Checksum

Not published yet (recommend adding checksum for downloadable files)

Verification Notes

GitHub-hosted reporting script that analyzes VM state history and deallocation patterns. Review module requirements and query scope before production use.

Safe Usage Checklist

  • Validate deallocation recommendations with workload owners to avoid impacting intentionally retained capacity.
  • Run against a small subscription set first to confirm performance and output format expectations.
  • Run in a non-production subscription/account/tenancy first and capture sample output before broader rollout.
  • Use least-privilege access. Current best hint from docs: Reader access to target Azure subscriptions with VM, Resource Graph, and monitoring metadata visibility.

Quick start (fast path)

Minimal steps to safely get value from this tool without reading the entire page first.

Estimated time: 10-15 minutes per subscriptionDifficulty: IntermediateAccess: Review / read-only
  1. 1. Confirm scope and permissions

    Use least privilege and test in a non-production scope first. Minimum access hint: Reader access to target Azure subscriptions with VM, Resource Graph, and monitoring metadata visibility.

  2. 2. Get the tool package / source

    View on GitHub and review the files before running.

    GitHub
  3. 3. Check prerequisites

    • ✅ PowerShell 5.1+ with Azure PowerShell modules (Az.Accounts, Az.Resources, Az.ResourceGraph, Az.Compute, Az.Monitor)
    • ✅ Azure authentication with appropriate subscription access permissions
    • ✅ Reader role on target Azure subscriptions for VM analysis
  4. 4. Run safely and review output

    GitHub-hosted reporting script that analyzes VM state history and deallocation patterns. Review module requirements and query scope before production use. Start with a small sample scope, then expand once results look correct.