Skip to content

Instantly share code, notes, and snippets.

@dfrankel33
Last active January 11, 2017 19:12
Show Gist options
  • Save dfrankel33/82b5bcbcb68e97c35946 to your computer and use it in GitHub Desktop.
Save dfrankel33/82b5bcbcb68e97c35946 to your computer and use it in GitHub Desktop.
#set servername variable
#$servername = read-host "Input server name"
$servernames = @("host1","host2","host3")
foreach ($servername in $servernames){
$server = rsc --refreshToken="abcd...wxyz" --host="us-3.rightscale.com" cm15 index /api/servers "filter[]=name==$servername"
$instancehref = (($server | ConvertFrom-Json).links | where rel -eq "current_instance").href
#start instance command:
rsc --refreshToken="abcd...wxyz" cm15 start $instancehref --host="us-3.rightscale.com"
#stop instance command:
#rsc --refreshToken="abcd...wxyz" cm15 stop $instancehref --host="us-3.rightscale.com"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment