How to send the process of Copy-SfItem to log file

  • 1
  • Question
  • Updated 2 months ago
  • (Edited)
We are exploring the ShareFile PowerShell SDK and we would like to copy from local machine to the SF drive. We looked at the example and we found what we want however as the files has thousands and thousands we would like to have a log so we can see which files are successfully copied over. There is a possibility while transferring to the cloud that long file name issue OR halfway through the internet cut off etc etc.

Any pointer that will be good. Thanks
Photo of DC Partners

DC Partners

  • 9 Posts
  • 0 Reply Likes

Posted 2 months ago

  • 1
Photo of Zack Eleveld

Zack Eleveld

  • 20 Posts
  • 4 Reply Likes
Are you trying to sync file by file or are you just pointing sync-sfitem at the directory and letting it determine what to sync? 
Photo of DC Partners

DC Partners

  • 9 Posts
  • 0 Reply Likes
I'm trying to copy the file across using Copy-SfItem command.
Photo of Zack Eleveld

Zack Eleveld

  • 20 Posts
  • 4 Reply Likes
It's better to use sync-SfItem in case is hasn't changed.  That said, if you are going item by item, why don't you have a step in your program after the Sync or Copy that verifies if the file on SF is the right size/date and if so, writes to a log file? If something doesn't match about the SF file, then write to a logfile as an error.  In powershell, you should be able to explore the properties of the SF item using the normal powershell commands and select-object *.
Photo of DC Partners

DC Partners

  • 9 Posts
  • 0 Reply Likes
The source of the file is never changed and that's why we use Copy-SfItem command. The reason we need the logs WHAT IF the when copied (by dragging the file across via ShareFile Drive Mapper) and the file path/name is too long. Are those files get skipped or have an error? We found that thumbs.db and *.tmp files are being skipped. Is that the case? 
(Edited)
Photo of Zack Eleveld

Zack Eleveld

  • 20 Posts
  • 4 Reply Likes
From your comments, it sounds like you are not currently using Powershell to do the upload/copy, but are doing it manually using the website or drive mapper?.  Then, you are considering a double check using powershell to make sure the directories are matching.  Please be more specific about how you are copying the files and how much Powershell you are currently using.
Photo of Jeremiah Strong

Jeremiah Strong

  • 24 Posts
  • 2 Reply Likes
I agree with Zack - after you upload the files could check for upload and comparison.

With that said, from your description it sounds like you only care about the failures. If this is true, then alternatively you could wrap your copy command in a try/catch block, then write this to a log file for further review. Just another thought.
Photo of DC Partners

DC Partners

  • 9 Posts
  • 0 Reply Likes
How do you check for the upload and comparison? Via the property of the folder in Windows Explorer for each folder (manually)?