Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Created August 10, 2015 17:57
Show Gist options
  • Select an option

  • Save Dalmirog-zz/393f78be09829e3ff3d0 to your computer and use it in GitHub Desktop.

Select an option

Save Dalmirog-zz/393f78be09829e3ff3d0 to your computer and use it in GitHub Desktop.
Bulk add/remove roles
##Module URL: http://dalmirog.github.io/OctoPosh/
##Function to add roles
function add-Machineroles([string]$rolename){
$machines = Get-OctopusMachine
foreach ($machine in $machines)
{
$machine.resource.roles.add($rolename)
}
$machines | Update-OctopusResource -Force -Verbose
}
#calling the function
add-Machineroles -rolename "MasterRole"
##Function to remove roles
function remove-machineroles($rolename){
$machines = Get-OctopusMachine
foreach ($machine in $machines)
{
$machine.resource.roles.remove($rolename)
}
$machines | Update-OctopusResource -Force -Verbose
}
#calling the function
remove-machineroles -rolename "MasterRole"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment