Skip to content

Instantly share code, notes, and snippets.

@gcanales75
Created May 31, 2015 00:50
Show Gist options
  • Select an option

  • Save gcanales75/7330a5406be16034486a to your computer and use it in GitHub Desktop.

Select an option

Save gcanales75/7330a5406be16034486a to your computer and use it in GitHub Desktop.
PoSh script para obtener servidores Rackspace Cloud usando REST
$uri = "https://identity.api.rackspacecloud.com/v2.0/tokens"
$user = "user"
$apiKey1 = "My-API-Key"
$account = "account"
$passcred = @{
"username"=$user
"apiKey"=$apiKey1
}
$auth = @{
"apiKeyCredentials"=$passcred
}
$body = @{
"auth"=$auth
}
$bodyJSON = ConvertTo-Json $body
$access = Invoke-RestMethod -Uri $uri -Method POST -ContentType 'application/json' -Body $bodyJSON
$token = $access.access.token.id
$uriServersListDetail = "https://dfw.servers.api.rackspacecloud.com/v2/$account/servers/detail"
$bodyServersDetail = @{
"X-Auth-Token"=$token
}
$RaxCloud = Invoke-RestMethod -Uri $uriServersListDetail -Method GET -Headers $bodyServersDetail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment