Copy-PWFolder with Versions?

Is there a way to Copy PW Folders with versions through PowerShell? 

The GUI has a checkbox to allow this but i cant see a switch in the PowerShell cmdlet

  • Not in one command. I got it to work by building a list of documents and then using Copy-PWDocumentsToFolder with the -IncludeVersions switch. Downside is the destination folder must exist already for Copy-PWDocumentsToFolder to work. Also I found a bug in the -PopulatePath option for Get-PWDocumentsBySearch.

    Anyway, this will backup files from one set of folders to another folder, maintaining the path of the original files and copying the versions.

    # Important to NOT use the -GetVersionsToo switch!
    # -PopulatePath doesn't populate the FolderPath property only the FullPath property
    # can use -Slow here or use split path on FullPath in loop
    $pwdList = Get-PWDocumentsBySearch -FolderPath 'Path\To\Source' -PopulatePath
    # Copy-PWDocumentsToFolder only accepts one target path, and it must exist so we have
    # to loop through each file to create its directory and calculate the target path
    ForEach ($pwd in $pwdList) {
        $fldr     = Split-Path $pwd.FullPath -Parent
        $bkupFldr = Join-Path "Backups" $fldr
        # Create folder everytime
        New-PWFolder -FolderPath $bkupFldr > $null
        $pwd | Copy-PWDocumentsToFolder -TargetFolderPath $bkupFldr -IncludeVersions


  • Oh, might be a bit of speed up doing some clever tricks with the folder paths:

    $fList = Split-Path $pwdList.FullPath -Parent | Sort -Unique
    ForEach ($f in $fList) {
        New-PWFolder -FolderPath (Join-Path 'Backups' $f) > $null

    create the folders first, then remove the New-PWFolder from the document copy loop


  • We have added a CopyVersions switch to the Copy-PWFolder cmdlet in today's PWPS_DAB release version  Note that the Copy-PWFolderBetweenDatasources has always copied versions when they included in the pipeline input.

    Mark Weisman | Bentley Systems

  • Thanks Mark, that would be a massive help! I'm assuming you meant, if so i have updated this morning but do not see the new switch?

  • You also need to use the -IncludeDocuments switch.  Try using this switch first, then press the - key and intellisense should present a list of switches.   Apparently, there are a lot of them.  You have to scroll down towards the bottom.  Then you'll see the CopyVersions switch. 

    Let us know if still have trouble with this.


    Mark Weisman | Bentley Systems