Created
August 10, 2015 17:57
-
-
Save Dalmirog-zz/393f78be09829e3ff3d0 to your computer and use it in GitHub Desktop.
Bulk add/remove roles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##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