ShareFileLogoThe Citrix ShareFile Sync application is quite limited in functionality, one of those limitations is that you can only synchronize to a single (one) local folder.

As Helge Klein wrote in his excellent article "Configuring Citrix ShareFile Sync from PowerShell" this is simply a GUI restriction and not a restriction in the actual ShareFile sync engine.

Helge describes that you can easily do this in PowerShell with the following example:

Add-SyncJob example powershell Download
Add-SyncJob -ApplicationId 1 -ApplicationName "PowerShell" -Account helgeklein.sharefile.com
-RemoteFolderName "foc86c19-d904-434a-9d67-xxxxxxxxxxxx" -LocalFolderPath "D:\Daten\Sync to ShareFile"
-AuthType 4 -UserName xxxxxx@helgeklein.com -SyncDirection 2 -Password "MY SHAREFILE PASSWORD"

While the command was accepted, nothing was synchronized.

I then created a Sync job with the Gui and noticed it had a different value for Authentication Type:

text Download
Id                 : 3
Account            : mydomain.sharefile.com
FolderId           : foh4e8f2-0fd2-42ae-a435-xxxxxxxxxxxx
User               : remko@mydomain.com
DeviceId           :
LocalFolderPath    : C:\Users\Remko\ShareFile\My Files & Folders
Application        : SFSyncEngine.SyncApp
Mode               : Bidirectional
Persist            : True
AuthenticationType : ShareFile
CachedJobState     : Idle

Notice that the AuthenticationType is not listed as an Integer but with it's name. The job that I added however had AuthenticationType 4 while I expected oauth_sharefile as per Helge's article.

Let's use PowerShell to tell us what the possible values are for AuthenticationType:

SFSyncEngine.AuthenticationType enum powershell Download
# Import SF Sync Engine Module
Import-Module 'C:\Program Files\Citrix\ShareFile\Sync\SFSyncEngine.dll'

# Get All Syncjobs, assuming there's at least one
$anyJob = (Get-SyncJobs -All)[0] # this doesn't work '| select -First 1

# Get the type (SFSyncEngine.AuthenticationType)
$type = $anyJob.AuthenticationType.GetType()

# list to store the enum names and values
$list = @()

# Get enum names and their value and add them to the list
$type.GetEnumNames() |  % { $item = "" | select name, value; $item.name = $_ ; $item.value = $type::$_.value__ ; $list += $item }

# show the list
$list | Format-List

Here's the output:

Output for SFSyncEngine.AuthenticationType text Download
name                              value
----                              -----
ShareFile                             0
Saml                                  1
WinAD                                 2
WinSso                                3

As you can see there is no value 4! Perhaps Helge used an older version of the Sharefile Windows Client or the Enterprise version. Shame on the developers though for documenting so badly and breaking stuff between versions and editions.

This is also shows two design principles of a REST API (which is what lies under the PowerShell commands) that I dislike:

  • REST does not require the client to know anything about the structure of the API.
  • REST expects the server to provide whatever information the client needs to interact with the service.

This means that there's little type safety and that input validation is often lacking.

To complete this post let's do the same trick for SyncDirection which type is

Output for SFSyncEngine.SyncMode text Download
name                              value
----                              -----
UploadOnly                            0
DownloadOnly                          1
Bidirectional                         2

I changed the AuthType param to 0 and now my folder is synchronizing.

Happy synching!