I would like to use PowerShell to upload files from several folders to Sharefile

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 3 weeks, 4 days ago.

  • Author
  • #78090



    I have several files that need to be uploaded to Sharefile monthly and I would like to use PowerShell to do this. I followed the steps here https://support.citrix.com/article/CTX207460 to add the ShareFile PowerShell snapin and installed the Sharefile Powershell SDK from GitHub but need some help.

    I tested by doing the following and get the prompt to enter credentials in Sharefile.

    Add-pssnapin sharefile
    New-sfclient –name “c:\temp\sflogin.sfps”
    $sfclient = get-sfclient –name “c:\temp\sflogin.sfps”
    New-psdrive –name sf –psprovider sharefile –root / -client $sfclient

    This works fine. Then I tested by doing a simple copy from a local directory to a directory in Sharefile as in the example below:
    Copy-sfitem c:\Temp\TestFolder-CommunicationTeam\CommunicationsPhoneTree.xlsx sf:/”Disaster Recovery-Business Continuity”\Communications

    If no files exist then the file is uploaded fine. However there are three things I am trying to accomplish:
    1. I want to copy select files, not the entire contents of the local directory. I know I can use (Copy-sfitem c:\temp\testfolder\* sf:/”Disaster Recovery-Business Continuity”\Communications) and this copies the entire directory. However, I just need to upload two excel files that periodically change each month from a variety of local folders. How do I do this?
    2. I need the files to be overwritten in Sharefile when they are uploaded. This doesn't happen if I use Copy-sfitem c:\Temp\TestFolder-CommunicationTeam\CommunicationsPhoneTree.xlsx sf:/”Disaster Recovery-Business Continuity”\Communications. How do I add the overwrite parameter in the command?
    3. I would need to copy local files from more than two dozen local directories to corresponding folders in Sharefile. I would like to efficiently do this using a script that doesn't require me to log into Sharefile as I do when I enter the $sfclient = get-sfclient –name “c:\temp\sflogin.sfps” command as noted above. How do I configure the script with the credentials so this doesn't need to run interactively? This will enable me to schedule the script to run automatically using the task scheduler.

  • #78237

    Don Jones

    Unfortunately it's not looking like anyone here has worked with this snap-in... you may want to see if Citrix' own support forums offer a better venue for asking? Really sorry to not be of help – this is just really specific to ShareFile.

    On #3, if the command doesn't offer a -Credential parameter, then there's no way around it. I don't have the command, however, so I can't see if that's the case or not.

You must be logged in to reply to this topic.