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

Parents
  • 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
    }
    
        

     

Reply
  • 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
    }
    
        

     

Children