ShareFile User Storage Report

January 24, 2017    sharefile powershell

Managing user storage

One of the ShareFile clients I am working for doesn’t want to utilize the quota system available in ShareFile, because that system only utilizes “hard quotas”. When a hard quota is set, it will alert the user when the amount of storage used meats a certain warning treshold, and when the user reaches the designated storage quotum, the user cannot store any more data in his Personal Folder. ShareFile doesn’t do “soft quotas” as of writing, which alerts the user that the treshold has been met but the user may continue storing new data.

Besides navigating to the Personal Folder of every single user and checking the used storage at the bottom of the page, there isn’t really a smart way to check how much data all users are actually storing on ShareFile in the WebApp.

API to save the day

Luckily, Citrix has a pretty good API which I am quite a fan of which we can use to retrieve this information. The ShareFile API is pretty well documented, as the website gives you a lot of information about all the entities, and you can log in to your ShareFile account on that page to use the API right away (be it in a very simple manner). There are code examples and how-to guides as well to get you started.

Using the API and the ShareFile PowerShell SDK, we can generate a report per user on the amount of data that they have stored. And since PowerShell is pretty neat in exporting data to several different formats, we can export the report in several pretty formats to be used by management without further editing. I created a script I can run (and schedule for periodic reporting) which retrieves all the Employee Home Folders and reports on the storage.

Prerequisites

  • .NET Framework 4.5 or later
  • PowerShell 4 or later
  • ShareFile PowerShell SDK

You can also check these (with verification and installation details) on the ShareFile PowerShell SDK wiki.

Generating access token

After you have installed the ShareFile PowerShell SDK, start the ShareFile PowerShell Console from the Start Menu or open PowerShell and load the module with Add-PSSnapin ShareFile.

First, you will need a ShareFile client token for authentication. You can generate this using the New-SfClient command. You either save it to a variable: $sfclient = New-SfClient; or you can save it to a file for later: New-SfClient -Name C:\full\path\to\token.sfps It will launch a ShareFile login window in which you enter your credentials (don’t forget to click on Sign in with company credentials if necessary). Make sure that the account you are entering is in the Superuser group. If you saved the token to a file, you can use it later using $sfClient = Get-SfClient -Name C:\full\path\to\token.sfps.

The script