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?
Thank you for pointing Get-PWFileHash out. I tend to think in terms of the PW SDK more than what's in PWPS_DAB because that's my background.
As you surmised, it does depend upon where the hash is calculated, and unfortunately, the generation of the hash that Get-PWFileHash provides is implemented with code because getting a PW File's hash isn't a feature of the PW SDK, so Get-PWFileHash copies the file out of the datasource in order to generate the requested hash.
IMHO, the primary benefit of PWPS_DAB over the PW SDK is that it is much easier to generate usable scripts than the effort behind generating similar applications using the PW SDK. A great feature of the PWPS_DAB module is that is has many Cmdlets that make using some of the features of the PW SDK much more "intuitive", or at least a lot fewer steps, than what you would have to do if you are using the PW SDK APIs directly. For example, getting and setting document attributes is much easier with PWPS_DAB than with the PW SDK APIs.
The "only advantages" that the PW SDK offers is potentially a bit faster performance (because you control the architecture and behaviors and may choose a "leaner" approach than a "general" approach to how data is obtained, stored and manipulated), and full access to all of the features available in the PW SDK since not all of these features have been made available via PWPS_DAB. And of course the PW SDK is the only choice if you need to generate a "native" application (can be built using managed code of course).
FWIW, looking at the code behind Get-PWFileHash, since it does copy out each file to your working directory that it is creating a hash for, this approach will take longer due to the file transfers in order to get the hash of the source and target files, then time to actually generate the hash of the source and target files, and then another file transfer from the source datasource to the target datasource. That's three file transfers instead of just one for a file that you need to overwrite, and two file transfers (vs. none!) if you don't need to overwrite the target file!
Obviously using this approach (getting each file's hash) would be best if you absolutely wanted to make sure that the file content is the same or if it is different regardless of any timestamps. Keep in mind though that this is not the approach that the Export-PWDocuments Cmdlet uses as it just compares the last modified timestamps and assumes that the file is newer if it is at least 1 minute newer than the target file and only transfers a single file if it needs to be overwritten.
As they say "design is just another word for compromise". Pick what works "best" for you.
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
Answer Verified By: Mark Shamoun