Stopped instance audit quick start
Structured quick-reference sections for prerequisites, installation, usage, and troubleshooting.
Prerequisites
- PowerShell 5.1+ or PowerShell Core for script execution
- Google Cloud CLI (`gcloud`) installed and authenticated
- Viewer-level access to target GCP projects and Compute Engine metadata
- Local output directory for CSV + HTML reports
Common parameters
| Parameter | Purpose | Example |
|---|---|---|
| -MinDays | Filters stopped instances by age | 30 |
| -ProjectIds | Targets specific GCP projects | "project1,project2" |
| -Zones | Limits scope to specific zones (if supported in your script version) | "us-central1-a,us-east1-b" |
Project scoping is the fastest way to validate output and permissions before broader scans.
Standard run path
- 1Run a baseline scan to discover stopped Compute Engine instances across accessible projects.
- 2Use `-MinDays 30` to focus on long-term stopped instances that are more likely cleanup candidates.
- 3Review attached persistent disks and static IPs before deciding on deletion or decommissioning.
- 4Use owner labels and project context to route follow-up to the right teams.
.\\GCP-StoppedInstances.ps1.\\GCP-StoppedInstances.ps1 -MinDays 30.\\GCP-StoppedInstances.ps1 -ProjectIds "project1,project2" -MinDays 30Outputs and prioritization
CSV + HTML output usage
| Signal | Why it matters | Action |
|---|---|---|
| Stopped duration | Separates temporary shutdowns from likely zombies | Prioritize oldest sleepers first |
| Project + zone | Identifies owner domain and operational context | Assign reviews to project owners |
| Owner labels | Speeds communication and approval | Validate intent before cleanup |
| Disk/storage context | Stopped VMs still incur disk costs | Snapshot/delete or resize where appropriate |
- Use the HTML report for stakeholder review and the CSV for sorting by age, project, and cost impact.
Troubleshooting
- If no resources are returned, confirm `gcloud auth list` and project visibility in the active account.
- If some projects fail, start with explicit `-ProjectIds` and verify IAM access per project.
- If scans are slow across many projects/zones, split the run by project group and compare outputs afterward.
Storage charges continue
Stopped GCE instances stop compute billing, but attached persistent disks and some network resources may continue billing until cleaned up.
PowerShell + gcloud CLI Excellence
Comprehensive analysis and reporting for stopped GCP compute instances with enterprise-grade performance
gcloud CLI Integration
Native integration with Google Cloud CLI for authenticated access and reliable data retrieval
Parallel Processing
High-performance parallel scanning across projects and zones with configurable concurrency limits
Multi-Project Discovery
Automatically discovers all accessible projects or targets specific projects for focused analysis
Zone Intelligence
Smart zone discovery with filtering capabilities and support for zone-specific targeting
Owner Detection
Extracts owner information from GCP labels for accountability and lifecycle management
Age Analysis
Calculates days since instance creation with configurable age-based filtering for lifecycle decisions
Dual Report Formats
Generates both CSV (for analysis) and HTML (for executive reporting) with comprehensive breakdowns
Performance Tracking
Real-time progress tracking with performance metrics and API call monitoring
Usage Examples
Real-world scenarios for GCP instance lifecycle management and optimization
Complete Organization Scan
.\GCP-StoppedInstances.ps1Discovers all stopped instances across your entire GCP organization with automatic project and zone discovery.
Age-Based Filtering
.\GCP-StoppedInstances.ps1 -MinDays 30Focuses on instances stopped for 30+ days for lifecycle management and potential cleanup decisions.
Targeted Project Analysis
.\GCP-StoppedInstances.ps1 -ProjectIds"project1,project2"Analyzes specific projects for focused resource management and compliance reporting.
Zone-Specific Scanning
.\GCP-StoppedInstances.ps1 -Zones"us-central1-a,us-east1-b"Limits analysis to specific zones for targeted optimization and reduced API calls.
Technical Specifications
Enterprise-grade PowerShell script with comprehensive GCP instance discovery capabilities
Requirements
Modern PowerShell with parallel job support and advanced cmdlets
gcloud CLI installed and configured with proper authentication
Active gcloud authentication with access to target projects
Compute Engine Viewer role or equivalent permissions across target projects
Internet access to Google Cloud API endpoints
Command Line Parameters
-ProjectIdsComma-separated list of GCP project IDs to scan
-ZonesComma-separated list of specific zones to scan
-MinDaysMinimum days since creation to include instances (default: 0)
-MaxConcurrentMaximum number of concurrent operations (default: 10)
-SkipZonesComma-separated list of zones to skip during scanning
Core Features
Discovery Engine
- • Automatic project and zone discovery via gcloud CLI
- • Parallel processing with configurable concurrency limits
- • PowerShell job-based parallel execution
- • Comprehensive error handling and retry logic
Data Processing
- • Instance age calculation with timezone handling
- • Owner extraction from GCP labels and tags
- • Machine type, region, and zone analysis
- • Disk size calculation and storage analysis
Reporting Capabilities
- • CSV export for data analysis and integration
- • Rich HTML reports with visual breakdowns
- • Age distribution analysis with priority levels
- • Project and region distribution charts
Performance Optimization
- • Concurrent gcloud API calls with job management
- • Progress tracking and performance metrics
- • Configurable concurrency limits for rate limiting
- • Memory-efficient data processing and aggregation
Comprehensive Reporting
Professional reporting in multiple formats with detailed analytics and visual breakdowns
CSV Data Export
Structured CSV export optimized for data analysis, filtering, and integration with business intelligence tools.
HTML Executive Report
Rich HTML report with visual analytics, age distribution charts, and executive-friendly presentation for stakeholder communication.
Chef's Tips & Best Practices
Professional recommendations for effective GCP instance lifecycle management
gcloud CLI Setup
Ensure gcloud is properly authenticated and configured before running the script. Like prepping your kitchen tools, proper setup ensures smooth operation.
Performance Tuning
Start with 5-10 concurrent jobs for large organizations to balance speed and API rate limits. Like managing multiple burners, find the right balance for your environment.
Project Strategy
Use project filtering for focused analysis or to avoid projects with restricted access. Target specific projects like a chef selecting ingredients from trusted suppliers.
Age-Based Filtering
Start with 30+ day filters for initial cleanup identification. Like aging ingredients, some instances need time, but others may be forgotten and ready for cleanup.
Owner Engagement
Use the owner detection to reach out before cleanup decisions. The script identifies owners through GCP labels, enabling proactive communication about instance lifecycle.
Report Integration
Import CSV reports into analytics tools for trend analysis. The structured output enables executive dashboards and automated lifecycle management workflows.
Ready to Optimize Your GCP Resources?
Download the GCP Stopped Instances Lister and start identifying optimization opportunities in your Google Cloud Platform today. PowerShell + gcloud CLI excellence for comprehensive instance discovery.
What to do next
Pick the path that fits where you are right now.