You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive PowerShell wrapper around the Octopus.Client.dll library that provides a "PowerShell-friendly" interface for interacting with Octopus Deploy instances (both cloud and on-premise).
π Features
Cross-Platform: Works on Windows PowerShell 5.1+ and PowerShell 7+ (Windows, Linux, macOS)
Pipeline Support: Most functions support pipeline input for flexible scripting
Argument Completion: Tab-completion for tenants, environments, projects, and more
Type Transformation: Automatic conversion of string inputs to Octopus resource objects
Saved Connections: Securely store connection configurations for easy reuse
Configuration as Code: Support for Git-based projects and runbooks
Comprehensive Coverage: 70+ cmdlets covering all major Octopus Deploy operations
# Option 1: Connect with credentials$apiKey="API-XXXXXXXXXXXXXX"|ConvertTo-SecureString-AsPlainText -Force
Connect-Octopus-OctopusServerURL "https://octopus.example.com"-ApiKey $apiKey# Option 2: Save configuration for automatic connectionSet-ConnectionConfiguration-OctopusServerURL "https://octopus.example.com"-ApiKey $apiKey# Test your connectionTest-OctopusConnection
Basic Examples
# Get all machines in Production environmentGet-Machine-Environment Production
# Get all tenants with a specific tagGet-Tenant-Tag "Region/US"# Deploy the latest release$release=Get-Release-Project "My Project"-Latest -Channel defaultInvoke-Deployment-Release $release-Environment Production -Tenant "MyTenant"# Run a runbook$runbook=Get-Runbook-Project "My Project"-Name "Maintenance"$snapshot=$runbook|Get-RunbookSnapshot-Published
Invoke-RunbookRun-RunbookSnapshot $snapshot-Environment Production
π Function Reference
Connection Management
Function
Description
Connect-Octopus
Establishes a connection to an Octopus Deploy instance
Test-OctopusConnection
Tests the current Octopus connection
Get-ConnectionConfiguration
Retrieves saved connection configuration
Set-ConnectionConfiguration
Saves connection configuration for reuse
Get-CurrentSpace
Gets the currently active Octopus space
Set-Space
Switches to a different Octopus space
Get-Space
Lists all available spaces
Projects & Project Groups
Function
Description
Get-Project
Retrieves project information
Get-ProjectGroup
Gets project groups
Remove-Project
Deletes a project
Get-ProjectTrigger
Lists project triggers
Get-Channel
Gets release channels for a project
Set-ReleaseChannel
Updates channel settings
Releases
Function
Description
Get-Release
Retrieves release information
New-Release
Creates a new release
Remove-Release
Deletes a release
Get-ReleaseTemplate
Gets the release template for a project
Get-ReleasePackageVersion
Lists package versions in a release
Get-PackageVersion
Gets available package versions
Deployments
Function
Description
Invoke-Deployment
Deploys a release to an environment
Get-Deployment
Retrieves deployment information
Get-CurrentDeployment
Gets currently active deployments
Get-DeploymentPreview
Previews a deployment without executing it
Get-DeploymentProcess
Gets the deployment process for a project
Get-DeploymentProcessSteps
Lists deployment process steps
Confirm-Intervention
Confirms a manual intervention
Get-OpenIntervention
Lists open manual interventions
Runbooks
Function
Description
Get-Runbook
Retrieves runbook information (supports CaC)
Invoke-RunbookRun
Executes a runbook
Get-RunbookRun
Gets runbook run information
Get-RunbookSnapshot
Retrieves runbook snapshots
Get-RunbookRunPreview
Previews a runbook run
Get-RunbookProcess
Gets the runbook process definition
Get-RunbookProcessStep
Lists runbook process steps
Set-RunbookSettings
Updates runbook settings
Machines (Targets)
Function
Description
Get-Machine
Lists deployment targets/machines
Get-MachineRole
Gets available machine roles
Get-MachinePolicy
Retrieves machine policies
Get-MachineConnectionStatus
Checks machine connectivity status
Add-RoleToMachine
Adds a role to a machine
Remove-RoleFromMachine
Removes a role from a machine
Set-Machine
Updates machine properties
Copy-MachinePolicy
Copies a machine policy
Tenants
Function
Description
Get-Tenant
Retrieves tenant information
New-Tenant
Creates a new tenant
Remove-Tenant
Deletes a tenant
Get-TenantProject
Lists projects associated with a tenant
Add-ProjectToTenant
Connects a project to a tenant
Remove-ProjectFromTenant
Disconnects a project from a tenant
Add-TagToTenant
Adds a tag to a tenant
Remove-TagFromTenant
Removes a tag from a tenant
Get-TenantMachineCount
Counts machines per tenant
Get-ProjectTenant
Gets tenants for a project
Add-TenantToTrigger
Adds a tenant to a project trigger
Remove-TenantFromTrigger
Removes a tenant from a trigger
Variables
Function
Description
Get-ProjectVariable
Gets project variables
Get-ProjectTenantVariable
Gets project template variables for a tenant
Set-ProjectTenantVariable
Sets project template variables
Get-CommonVariable
Gets common (library) variables
Get-CommonTenantVariable
Gets common tenant-specific variables
Set-CommonTenantVariable
Sets common tenant variables
Get-VariableSet
Lists variable sets
Get-VariableSnapshot
Gets variable snapshot for a release
Environments & Lifecycles
Function
Description
Get-Environment
Lists environments
Get-Lifecycle
Gets lifecycle information
Tags
Function
Description
Get-TagSet
Lists tag sets and tags
Tasks
Function
Description
Get-Task
Retrieves task information
Get-TaskResult
Gets task execution results
Get-TaskStatus
Checks task status
Get-TaskType
Lists available task types
Stop-Task
Cancels a running task
Invoke-TaskScript
Executes a script in task context
Artifacts
Function
Description
Get-Artifact
Lists artifacts
Get-ArtifactContent
Retrieves artifact content
Save-Artifact
Saves an artifact to disk
Remove-Artifact
Deletes an artifact
Git Integration (Configuration as Code)
Function
Description
Get-GitBranch
Lists Git branches for a CaC project
Get-GitReference
Gets Git references
Get-SourceScriptsInGit
Retrieves scripts from Git repository
Script Modules
Function
Description
Get-ScriptModule
Lists script modules
Advanced
Function
Description
Get-OctopusRepositoryObject
Generic method to retrieve any repository object
π‘ Common Use Cases
Working with Tenants
# Get all tenants in a specific regionGet-Tenant-Tag "Region/US"|Select-Object Name, Id
# Count machines per tenant in productionGet-Tenant|Get-TenantMachineCount-Environment Production -MachineRole DatabaseServer
# Add a project to multiple tenants$tenants=Get-Tenant-Tag "Rolloutgroups/Wave-1"foreach ($tenantin$tenants) {
Add-ProjectToTenant-Project "My App"-Tenant $tenant-Environment Development, Production
}
Managing Variables
# Get project variablesGet-ProjectVariable-Project "My Project"# Set multiple tenant variables at once$variables=@{
'DatabaseServer'='sql.example.com''DatabasePort'='1433''DatabaseName'='MyDatabase'
}
Set-CommonTenantVariable-Tenant "MyTenant"-VariableSet "Customer Variables"-VariableHash $variables# Clear a tenant variable (reset to default)Set-CommonTenantVariable-Tenant "MyTenant"-VariableSet "Customer Variables"-Name "DatabaseServer"-Value ""
Release Management
# Create a release with specific package versions$packages=@{
'MyApp.Web'='1.2.3''MyApp.Api'='1.2.4'
}
New-Release-Project "My Application"-Package $packages-Version "1.2.3"# Get the latest release and deploy it$release=Get-Release-Project "My App"-Latest -Channel default$tenants=Get-Tenant-Tag "Rolloutgroups/Wave-1"foreach ($tenantin$tenants) {
Invoke-Deployment-Release $release-Environment Production -Tenant $tenant
}
Runbook Automation
# Run maintenance runbook across all tenants$runbook=Get-Runbook-Project "Infrastructure"-Name "Database Backup"$snapshot=$runbook|Get-RunbookSnapshot-Published
$tenants=Get-Tenantforeach ($tenantin$tenants) {
Invoke-RunbookRun-RunbookSnapshot $snapshot-Environment Production -Tenant $tenant
}
Machine Management
# Find all machines with a specific roleGet-Machine-Role "DatabaseServer"|Select-Object Name, HealthStatus, Roles
# Add a role to all machines in an environmentGet-Machine-Environment Production |Add-RoleToMachine-Role "WebServer"# Get machines for a specific tenant and environmentGet-Machine-Tenant "MyTenant"-Environment Production |Select-Object Name,@{N='Environment'; E={(Get-Environment-ID $_.EnvironmentIds).Name}}
π§ Advanced Features
Pipeline Support
Most functions support PowerShell pipeline for flexible scripting:
# Chain commands togetherGet-Project-Name "My App"|Get-Release-Latest |Get-ReleasePackageVersion# Process multiple itemsGet-Tenant-Tag "Region/US"|Get-TenantMachineCount-Environment Production |Sort-Object Count -Descending
Argument Completion
The module provides tab-completion for many parameters:
Get-Machine-Tenant <TAB># Completes with tenant namesGet-Project-Name <TAB># Completes with project namesGet-Environment<TAB># Completes with environment names
Working with Multiple Spaces
# Check current spaceGet-CurrentSpace# Switch spacesSet-Space-Name "DevOps"# List all spacesGet-Space
Configuration as Code Support
# Get runbooks from a specific Git branchGet-Runbook-Project "My CaC Project"-BranchName "feature/new-deployment"# Get available branchesGet-GitBranch-Project "My CaC Project"# Get source scripts from GitGet-SourceScriptsInGit-Project "My CaC Project"
Contributions are welcome! This module is developed "as is" and functions are added as needed. Please note that breaking changes may occur in future versions.
οΏ½π License
Copyright (c) 2025 Emrys MacInally. All rights reserved.
Breaking changes may occur in future versions as the module evolves
Always test in a non-production environment first
Secure your API keys properly using SecureString
π Support
For issues, questions, or contributions, please visit the GitHub repository.
π Special Thanks
Special thanks to Marvin Becker for his valuable contributions to this project. His work has helped improve and extend the functionality of this module.