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


Reply Children
No Data