Overwriting files with Copy-PWDocumentsBetweenDatasources?

Hi all,

I am using the Copy-PWDocumentsBetweenDatasources cmdlet to copy files from one datasource to another. The one thing ive found is that I am unable to overwrite any files that already exist in the Target.

Is this a limitation of Copy-PWDocumentsBetweenDatasources? Also, is there any way to get a similar result as Export-PWDocuments where only newer files get updated?



  • Mark,

    Yes, this is a limitation of Copy-PWDocumentsBetweenDatasource() because it is using the API function aaApi_CopyDocuments() which behaves that way.

    One way to get similar results, i.e. "newer files get updated" would be to script it - in your script check to see if the source file already exists in the target datasource, and if it does, delete it, move it or rename it out of the way before you copy the document.  

    I was curious about how "popular" this Cmdlet is so I looked using this command:

    Get-PWCmdletStatistics | Sort-Object -Property Datasources -Descending

    At this moment, the most used Cmdlet (of course) is PW-NewLogin.

    > Get-PWCmdletStatistics -CmdletName New-PWLogin
    Cmdlet      Executions Datasources EarliestData        
    ------      ---------- ----------- ------------        
    New-PWLogin    3678004        2647 11/6/2018 8:20:05 PM

    And Copy-PWDocumentBetweenDatasources has this usage:

    > Get-PWCmdletStatistics -CmdletName Copy-PWDocumentsBetweenDatasources
    Cmdlet                             Executions Datasources EarliestData        
    ------                             ---------- ----------- ------------        
    Copy-PWDocumentsBetweenDatasources     246294          24 11/6/2018 8:19:23 PM

    I can't say if it will be update to behave like you asked but I'm wondering if using Export/Import Cmdlets would solve your problem?

    Dan Williams
    Solution Consultant
    Bentley Systems, Incorporated
    Portland, OR, USA (Pacific Time UTC-08:00)

    Answer Verified By: Mark Shamoun 

Reply Children