Dune PSModule - Examples¶
Login to Dune¶
# Login with social auth
Connect-Dune -Tenant "yendico"
# Disconnect and remove cached session
Disconnect-Dune
List dune collection and deployments¶
# List all collections
Get-DuneCollection
# List all deployments by displayname
Get-DuneDeployment
# Get a deployment by displayname
Get-DuneDeployment -DisplayName "Web Server"
# Get all deployments from web collection
Get-DuneCollection -Name "web" | Get-DuneDeployment
# List all DuneResourceGroup for a deployment
Get-DuneDeployment "webserver" | Get-DuneResourceGroup
List resources¶
# Llist all resources for a deployment
Get-DuneDeployment "webserver" | Get-DuneResource
# Get-DuneComputeNode
Get-DuneComputeNode -Hostname "server1"
# Get all ServiceAccounts
Get-DuneGenericResource -ExtType "dune/ServiceAccount"
# List all disks for a computenode
Get-DuneComputeNode -Name "webvm" | Get-DuneDisk
Display computenode insights¶
# Get pending updates for a computenode
Get-DuneComputeNode -Hostname "server1" | Get-DuneUpdate
# List services for a computenode
Get-DuneComputeNode -Hostname "server1" | Get-DuneService
# List package for a computenode
Get-DuneComputeNode -Hostname "server1" | Get-DunePackage
# Show facts for a computenode
Get-DuneComputeNode -Hostname "server1" | Get-DuneFacts
Deployment Operations¶
# Start a deployment
Get-DuneDeployment "webserver" | Start-DuneDeployment -Id <deployment-guid>
# Stop a deployment
Get-DuneDeployment "webserver" | Stop-DuneDeployment -Id <deployment-guid>
# Set deployment lifetime to expire in 30 days
Get-DuneDeployment "webserver" | Set-DuneDeploymentLifetime -ValidUntil (Get-Date).AddDays(30)
# Remove a deployment (use -WhatIf first to preview)
Remove-DuneDeployment -Id <deployment-guid> -Unstage -WhatIf
ComputeNode Operations¶
# Start ComputeNode
Get-DuneComputeNode -Hostname "server1" | Start-DuneComputeNode
# Stop ComputeNode
Stop-DuneComputeNode -Id <computenode-guid>
Actions & ActionAssignments¶
# List all actions
Get-DuneAction
# List actions assignments for a deployment
Get-DuneDeployment "webserver" | Get-DuneActionAssignment
# List resource for a action assignment
Get-DuneActionAssignment -Name "Start WebServer" | Get-DuneResource
# Start action assignment
Get-DuneComputeNode "webserver" | Get-DuneActionAssignment -Name "Start WebServer" | Start-DuneActionAssignment
# List all jobs for an action assignment
Get-DuneComputeNode "webserver" | Get-DuneActionAssignment -Name "Start WebServer" | Get-DuneJob
# Show JobEvents for the recent action job of an action assignment
Get-DuneComputeNode "webserver" | Get-DuneActionAssignment -Name "Start WebServer" | Get-DuneJob | Select -Last 1 | Get-DuneJobEvent
# Assign a action to a deployment
Get-DuneAction -Name "service-manager" | New-DuneActionAssignment -Deployment (Get-DuneDeployment "webserver")
# Assign a action to a resource
Get-DuneAction -Name "service-manager" | New-DuneActionAssignment -Resource (Get-DuneComputeNode -Hostname "server1")
Resource provider & configuration¶
# Create a new provider
New-DuneResourceProvider -Name "yendico-prod-sub" -Type "azure" -DefaultEnvironment Dev
# Initialize a provider
Get-DuneResourceProvider -Name "yendico-prod-sub" | Invoke-DuneResourceProviderInitialization
# Remove a provider (use -WhatIf)
Remove-DuneResourceProvider -Id <provider-guid>
Users, variables and settings¶
# List users
Get-DuneUser -FirstName "Jane"
# Get and remove a variable (resource or resource-group scoped)
Get-DuneVariable -ResourceGroup "rg-app"
Remove-DuneVariable -Name "MyVar" -ResourceGroup <id> -Confirm
Permissions¶
A permission grants a user a role on a config item (tenant, collection, deployment, resource group or resource) and is inherited through the structure — see Authorization.
# List all permissions granted on a deployment
Get-DuneDeployment webserver_dev | Get-DunePermission
# List all permissions of a user
Get-DuneUser -Email "jane.doe@yendico.ch" | Get-DunePermission
# Grant a user the Operator role on a deployment
$User = Get-DuneUser -Email "jane.doe@yendico.ch"
Get-DuneDeployment webserver_dev | Add-DunePermission -User $User -RoleName Operator
# Grant several users the same role in one call
$Users = Get-DuneUser -LastName "Doe"
Get-DuneDeployment webserver_dev | Add-DunePermission -User $Users -RoleName Operator
# Grant using a role object instead of its name
$Role = Get-DuneRole Operator -AppliesTo Deployment # AppliesTo must match the type of the config item
Get-DuneDeployment webserver_dev | Add-DunePermission -User $User -Role $Role
# Revoke a single user's permission on a deployment (use -WhatIf first to preview)
Get-DuneDeployment webserver_dev | Get-DunePermission |
Where-Object UserId -eq $User.Id |
Remove-DunePermission -WhatIf
# Revoke all permissions of a user
Get-DuneUser -Email "jane.doe@yendico.ch" | Get-DunePermission | Remove-DunePermission
Note
A role name is only unique together with its AppliesTo — there is a separate Owner role for each config item type. Add-DunePermission -RoleName handles that for you: pass just the name (for example Operator or Owner, matching case) and the API picks the role that fits the target's type.
Add-DunePermission -Role takes a DuneRole object instead. You then have to fetch the right variant yourself with Get-DuneRole <name> -AppliesTo <type>, and its AppliesTo must match the target or the API rejects the call.
Best Practices & Notes¶
- Use
Get-Help <cmdlet> -Examplesto see parameter-set examples added to each function. - Destructive cmdlets support
ShouldProcess; use-WhatIfand-Confirmto preview or require confirmation. - Use pipeline-friendly commands to compose operations (most
Get-*return objects accepted by child objectsGet-*,Start-*,Stop-*,Remove-*). - Keep credentials and tokens secure — prefer
Get-Credentialor external secret stores.
This guide is intentionally short — run Get-Help inside PowerShell for precise parameter sets and examples for each public function.