Skip to content
Peter Schulz edited this page May 8, 2014 · 31 revisions

Welcome to the ShareFile-PowerShell wiki!

Example usage: USAGE-AUTHENTICATION Once you have the snap-in registered, you can use in PowerShell as follows:

Load the snap-in: Import-Module ShareFileSnapIn.dll

Authenticate to a session (and save for future use): New-SfClient –Name mySubdomain

Note: The name provided here will be used to save the oAuth token for this connection. Subsequent scripts can access this user session without requiring an interactive user login or putting a password in your script. You should protect this token file as if it were credentials, though it can be revoked in the ShareFile application indepenent of password if there is ever a concern of inappropriate access.

Load a saved session: $sfClient = Get-SfClient –Name mySubdomain

USAGE-API Once you have a session, you can make calls to the API as follows: Send-SFRequest –Client $sfClient –Method GET –Entity Users

Documentation for the ShareFile API entity model and more information is available here: https://developer.sharefile.com

USAGE-PROVIDER This snap-in also includes a provider that will allow you to access ShareFile content from within your scripts. This is useful for scripting out sync tasks that need to run unattended or to sync specific folders or in specific ways (like unidirectional sync.)

Create the provider: New-PSDrive -Name sf -PSProvider ShareFile -Root / -Client $sfClient

Access the provider: Set-Location sf:

Copy files to/from ShareFile: Copy-SFItem sf:/Folder/Folder C:\LocalFolder Copy-SFItem C:\LocalFolder* sf:/Folder

Note: You can also use del (Remove-Item), cd (Set-Location), and dir (Get-ChildItem).

Clone this wiki locally