Find Communities by: Category | Product


September 25, 2013 Previous day Next day


As a NAS Specialist at EMC, I frequently get customer requests for scripts to automate tasks on Isilon.  To that end, over the past year or so, I've developed several Powershell scripts to automate tasks on Isilon clusters using SSH and "isi" CLI commands. With the introduction of the new RESTful platform API (PAPI) there is now a much easier and more elegant way to automate and manage  Isilon clusters using Powershell. This first blog post on the topic will show you the basics on how to connect to a cluster using Powershell and the PAPI and I'll create additional posts to demonstrate more complex examples (ex. creating quotas).

Before we dig into Powershell specifics, I highly recommend you download and read the latest PAPI reference guide on (7.0.2 can be found here).

Because the PAPI provides access to the cluster via REST we can manipulate resources using HTTP methods like GET, POST, PUT, and DELETE.  The representations of objects and collections are exchanged as JSON formatted documents (more on that later).

To use the PAPI you will of course need to enable HTTP on the cluster (Protocols-->HTTP Settings-->Enable HTTP)


Powershell v3

Because we will be working with REST and JSON, it's best if you use Powershell v3 because it has built-in methods (ex. "Invoke-RestMethod) that simplify RESTful access.   You can check your current Powershell version by looking at the $PSVersionTable value:


If you don't have version 3 you will first need to make sure you have the .NET Framework version 4 found here.

You can then download and install the appropriate v3 management framework here.

Connecting to the cluster

Take a look at the attached script and you'll see that the script accepts parameters for an Isilon IP address or hostname, a username and password:

# Accept input parameters



To access the resources on the cluster we will use the "Invoke-RestMethod" with the appropriate parameters.  This method takes several parameters such as a URI string, a body (used for a POST), headers, etc.  The following code will build the header information we need and the base URL for access.

# Encode basic authorization header and create baseurl

$EncodedAuthorization = [System.Text.Encoding]::UTF8.GetBytes($username + ':' + $password)

$EncodedPassword = [System.Convert]::ToBase64String($EncodedAuthorization)

$headers = @{"Authorization"="Basic $($EncodedPassword)"

$baseurl = 'https://' + $isilonip +":8080"

Now we need to decide which resource we want to access (quota in this example) and add it to the base URL to create the final URI that we'll pass to  "Invoke-RestMethod".  If you take a look at the PAPI documentation you'll see that a collection of resources are accessed in the following format "/platform/1/<namespace>/<collection-name>".  So if for example, we want to get the collection of objects representing all of the quotas defined on the cluster we need to get "/platform/1/quota/quotas".

$resourceurl = "/platform/1/quota/quotas"

$uri = $baseurl + $resourceurl


All that's left now is to  call Invoke-RestMethod and then access to the returned object that contains the quota collection:

$ISIObject = Invoke-RestMethod -Uri $url -Headers $headers -Method Get



So, let's run the script to see what we get (the output of course will be much more interesting if you have at least one quota defined):

script input.png


Voila, we see a list of all of the quotas (and their properties) defined on the cluster!

Notice that I didn't do anything to format the output I got back from the Invoke-RestMethod?  That's the beauty of using this method in PSv3, it automatically converts the JSON output into objects.


That's all for this post, in the next post I'll cover the slightly more complicated process of creating a resource object (I'll create a quota as an example).

Filter Blog

By date:
By tag: