ShareFile-PowerShell icon indicating copy to clipboard operation
ShareFile-PowerShell copied to clipboard

Copy files from various onsite directories to corresponding folders in Sharefile

Open Vallee2017 opened this issue 8 years ago • 1 comments

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 snap 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.

Thanks, Roger

Vallee2017 avatar Aug 25 '17 12:08 Vallee2017

$sfclient = New-sfclient –name “c:\temp\sflogin.sfps” You only have to do this once

Once you have set $sfclient you can call it by doing this in your script: $sfclient = Get-SfClient –name “c:\temp\sflogin.sfps”

ghost avatar Nov 09 '17 20:11 ghost