PowerShell CloudIn a post from last year, Steven Swenson explained how to use the Invoke-RestMethod cmdlet in PowerShell to query the Cloud Office REST API.

Since that time, I published Invoke-RsCloudOfficeRequest, a PowerShell module that takes all the work out of interacting with the Rackspace Cloud Office REST API.  It handles:

  • Passing the authentication header
  • Encoding PowerShell input into the expected body format
  • Parsing error responses into a meaningful format
  • Unpaginating paged responses
  • Storing API credentials so you don’t have to type them in every time (Optional)

But enough talk, let’s learn how to use it.

Set Up

In PowerShell 5, installation is as easy as:

Tip: For earlier versions, see the project site for manual installation instructions.

Next, you need your Rackspace Cloud Office API keys. If you do not have a Rackspace Cloud Office Super Admin account, you can go here to learn what Cloud Office is all about.

First log in to the Cloud Office Control Panel, then navigate to the API Keys page.

API keys page sceenshot

Tip: If you run into issues, check out this knowledge center article.

Take note of the User Key and Secret Key from that page. For convenience, you can save the keys with the following command so you don’t have to type them in for every request:

Note: Replace the example keys with your actual keys.

Now we’re ready to start interacting with the API.

Usage

We’re going to experiment with the Admin endpoint to see how Invoke-RsCloudOfficeRequest can be used.

To get a list of all administrators on the account, run:

Let’s add a new administrator in order to try out the functionality:

Now we can get the details of the admin we just added:

We can edit the admin:

And finally we can delete the admin:

The Cloud Office REST API supports a lot more than just editing admins. Check out the project homepage for an example of querying domains and editing mailboxes, and check out the project wiki for cookbook-like examples of accomplishing specific tasks.

That concludes the basic introduction. Tell me, reader, what do you want to accomplish with Invoke-RsCloudOfficeRequest?

What cookbook examples do you want to see?

Let me know by submitting an issue to the project.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS