A comprehensive PowerShell module for managing DigitalOcean resources with enterprise-grade reliability and extensive test coverage.
π New Remove-DigitalOceanDroplet Function
- β¨ New Function: Remove-DigitalOceanDroplet with dual deletion methods
(by ID or tag) - π‘οΈ Enhanced Security: High-impact confirmation with ShouldProcess
support (WhatIf/Confirm) - π Comprehensive Testing: 9 dedicated unit tests plus 16 integration
tests for real API validation - π Excellent Coverage: Maintained 94.12% test coverage with 541
total tests passed - β Production Ready: Fully validated with real DigitalOcean API calls
- π― Robust Error Handling: Detailed API error parsing with verbose
logging and user-friendly messages - π§ Bulk Operations: Support for deleting multiple droplets using tags
- π Complete Documentation: Full help documentation with examples
β
Complete PowerShell Module with proper structure and modern
development practices
β
94.12% Test Coverage with 541 comprehensive tests
(541 passed, 0 failed, 2 skipped) using Pester v5
β
Class-based Architecture with strongly-typed PowerShell classes for
Account, Team, Image, Region, Size, SSH Key, VPC, Volume, and
Droplet objects
β
Comprehensive Error Handling and defensive programming patterns
throughout
β
CI/CD Pipeline with Azure Pipelines configuration for automated
testing and deployment
β
Professional Documentation with detailed help files, examples, and
inline documentation
β
Modern Build System using Sampler framework with
ModuleBuilder integration
β
Enterprise Ready with full parameter validation, pagination support, and
robust API integration
π§ Bug Fix and Error Handling Enhancement
- π Fixed: New-DigitalOceanVolume API integration issues resolved
- οΏ½ Enhanced Error Handling: Improved API error reporting with detailed response parsing
- οΏ½ Documentation: Updated New-DigitalOceanDroplet parameter documentation
- π§ͺ Integration Testing: Added critical integration testing requirements for non-GET functions
- π Test Coverage: Maintained excellent 95.89% coverage with 549 tests
- β Quality Assured: Real API validation ensures production reliability
Install-Module -Name PSDigitalOcean -Scope CurrentUsergit clone https://github.com/your-username/PSDigitalOcean.git
cd PSDigitalOcean
.\build.ps1 -Tasks buildBefore using the module, you need to set your DigitalOcean API token:
# Method 1: Use the provided function (Recommended)
Add-DigitalOceanAPIToken -Token "your-api-token-here"
# Method 2: Set manually as environment variable
[Environment]::SetEnvironmentVariable(
"DIGITALOCEAN_TOKEN",
"your-api-token-here",
[System.EnvironmentVariableTarget]::User
)Get your API token from the DigitalOcean Control Panel.
# Get account with pagination
Get-DigitalOceanAccount -Page 1 -Limit 20
# Get all accounts at once
Get-DigitalOceanAccount -All# Get images with pagination
Get-DigitalOceanImage -Page 1 -Limit 20
# Get all images at once
Get-DigitalOceanImage -All
# Filter by image type
Get-DigitalOceanImage -Type "application"
Get-DigitalOceanImage -Type "distribution"# Get sizes with pagination
Get-DigitalOceanSize -Page 1 -Limit 20
# Get all sizes at once
Get-DigitalOceanSize -All# Get all SSH keys
Get-DigitalOceanSSHKey
# Get a specific SSH key by name
Get-DigitalOceanSSHKey -SSHKeyName "my-laptop-key"# Get volume by ID
Get-DigitalOceanVolume -VolumeId "506f78a4-e098-11e5-ad9f-000f53306ae1"
# Get volumes by name
Get-DigitalOceanVolume -VolumeName "my-volume"
# Get volumes in a specific region
Get-DigitalOceanVolume -Region "nyc1"
# List all volumes with pagination
Get-DigitalOceanVolume -Page 1 -Limit 20
# Get all volumes at once
Get-DigitalOceanVolume -All# Get all VPCs
Get-DigitalOceanVPC
# Filter VPCs by name
Get-DigitalOceanVPC | Where-Object { $_.Name -like "*production*" }
# Get specific VPC properties
Get-DigitalOceanVPC | Select-Object Name, IpRange, Region# Create a basic droplet
New-DigitalOceanDroplet -DropletName "web-server" -Size "s-1vcpu-1gb" -Image "ubuntu-20-04-x64"
# Create a droplet with additional features
New-DigitalOceanDroplet -DropletName "production-server" -Size "s-2vcpu-2gb" -Image "ubuntu-20-04-x64" -Backups $true -Monitoring $true -Tags @("production", "web")
# Create a droplet with SSH key and user data
$sshKey = Get-DigitalOceanSSHKey | Where-Object { $_.name -eq "my-key" }
$userData = @"
#!/bin/bash
apt update
apt install -y nginx
systemctl start nginx
"@
New-DigitalOceanDroplet -DropletName "nginx-server" -Size "s-1vcpu-1gb" -Image "ubuntu-20-04-x64" -SSHKey $sshKey -UserData $userData
# Preview droplet creation with -WhatIf
New-DigitalOceanDroplet -DropletName "test-server" -Size "s-1vcpu-1gb" -Image "ubuntu-20-04-x64" -WhatIfThe module returns strongly-typed PowerShell class objects:
$account = Get-DigitalOceanAccount
Write-Host "Account Email: $($account.email)"
Write-Host "Droplet Limit: $($account.droplet_limit)"
Write-Host "Team Name: $($account.team.name)"
$sizes = Get-DigitalOceanSize -All
foreach ($size in $sizes) {
Write-Host "Size: $($size.ToString())"
Write-Host "Memory: $($size.Memory) MB, vCPUs: $($size.Vcpus)"
Write-Host "Available Regions: $($size.Regions -join ', ')"
}- Team: Represents DigitalOcean team information with UUID and name
- Account: Complete account object with limits, verification status, and
team association - DigitalOceanImage: Represents DigitalOcean images with comprehensive
metadata and properties - DigitalOceanRegion: Represents DigitalOcean regions with features,
availability, and supported sizes - DigitalOceanSize: Represents DigitalOcean Droplet sizes with pricing,
specifications, and regional availability - DigitalOceanVPC: Represents DigitalOcean Virtual Private Clouds with
network configuration and regional information - DigitalOceanDroplet: Represents DigitalOcean Droplets with comprehensive
server configuration and status information - Root: Container class for account responses
- Invoke-DigitalOceanAPI: Core API client with full HTTP method support
- Get-DigitalOceanAPIAuthorizationBearerToken: Secure token management
- Comprehensive Error Handling: Graceful handling of API failures and edge cases
- 471 Tests across all functionality
- 98.95% Code Coverage exceeding industry standards
- Unit Tests for all public and private functions
- Integration Tests for real DigitalOcean API interaction scenarios
- Class Coverage Tests ensuring all PowerShell classes work correctly
- PSScriptAnalyzer compliance for code quality
- Pester v5 testing framework
- Automated CI/CD pipeline with Azure DevOps
- Code Coverage Reports with detailed analysis
- PowerShell 5.1 or PowerShell 7+
- Pester v5.7.1+
- Sampler build framework
# Install dependencies and build
.\build.ps1 -AutoRestore -Tasks build
# Run all tests
.\build.ps1 -AutoRestore -Tasks test
# Build and test in one command
.\build.ps1 -AutoRestorePSDigitalOcean/
βββ source/
β βββ Classes/ # PowerShell class definitions
β βββ Private/ # Internal functions
β βββ Public/ # Exported functions
β βββ en-US/ # Help documentation
βββ tests/
β βββ Unit/ # Unit tests for all functions
β βββ Integration/ # Integration tests for real API scenarios
β βββ QA/ # Quality assurance tests
βββ output/ # Build artifacts
βββ build.ps1 # Build scriptAdd-DigitalOceanAPIToken- Securely store DigitalOcean API token with
cross-platform supportGet-DigitalOceanAccount- Retrieve account information with pagination supportGet-DigitalOceanImage- Retrieve DigitalOcean images with filtering and
pagination supportGet-DigitalOceanRegion- Retrieve DigitalOcean regions with pagination supportGet-DigitalOceanSize- Retrieve DigitalOcean Droplet sizes with pagination supportGet-DigitalOceanSSHKey- Retrieve SSH keys from DigitalOcean account with
filtering supportGet-DigitalOceanVolume- Retrieve DigitalOcean volumes with support for
ID, name, and region-based filteringGet-DigitalOceanVPC- Retrieve Virtual Private Cloud (VPC) information from
DigitalOcean accountNew-DigitalOceanDroplet- Create new DigitalOcean Droplets with
comprehensive configuration options including SSH keys, backups,
monitoring, and user dataNew-DigitalOceanVolume- Create new DigitalOcean volumes with filesystem
configuration and snapshot supportRemove-DigitalOceanDroplet- Remove DigitalOcean droplets by ID or tag
with comprehensive error handling and ShouldProcess supportRemove-DigitalOceanVolume- Remove DigitalOcean volumes by ID or
name+region with comprehensive error handling and ShouldProcess support
Get-DigitalOceanAPIAuthorizationBearerToken- Token managementInvoke-DigitalOceanAPI- Core API communication
We welcome contributions!
Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure all tests pass:
.\build.ps1 -Tasks test - Submit a pull request
This project is licensed under the MIT License β see the
LICENSE file for details.
- Droplet Management - Create DigitalOcean Droplets with comprehensive options
- Additional DigitalOcean resource support (Volumes, Load Balancers, etc.)
- Advanced Droplet management (Get, Update, Delete, Snapshots)
- PowerShell 7 cross-platform compatibility testing
- Advanced filtering and search capabilities