Export-PWDocuments is not exporting documents from my Projects but "Export to Excel" does.
I noticed a considerable difference in the number of files reported by PW and that exported using Export-PWDocuments, I did a comparison using "Export to Excel" which gave me almost the same number of files on checking the log I found some files where not exported due to long paths.However Export-PWDocumants does not have a log option so I cannot check for export errors.Is there any way I can get Export-PWDocuments to create an export log similiar to "Export to Excel"?
Can you post your code, or a code snippet of how you are using Export-PWDocuments?
Many folks tend to turn off error handing (-EA SilentlyContinue, or with $ErrorActionPreference), so how are you handling errors?
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
# Stop this script if there are any errors
$ErrorActionPreference = 'Stop'
# Write out all debug and verbose messages
$DebugPreference = 'Continue'
$VerbosePreference = 'Continue'
# Check if the PWPS & PWPS_DAB modules are loaded and load it if necessary
$pwpsModule = Get-Module pwps
$pwps_dabModule = Get-Module pwps_dab
# Open an Admin Connection
Open-PWConnection -Admin -DatasourceName $datasource -UserName $username -Password $Password
$StartTime = (Get-Date -format u)
Export-PWDocuments -OutputFolder "c:\TMP\PowerShell\Organisational Docs" -ProjectWiseFolder "Organisational Docs" -ExportMetadata -ExportMetadataFile "c:\TMP\PowerShell\metadata_OrganisationalDocs.xlsx"
$EndTime = (Get-Date -format u)
# Log Out of ProjectWise
NEW-TIMESPAN -Start $StartTime -End $EndTime
But as we have 12000+ Documents I can not see which one gives the error
instead of exporting by the folder path you could try exporting files individually and see if you catch the error that way:
Get-PWDocumnetsBySearch -FolderPath "Organisational Docs" -Slow | Export-PWDocuments -OutputFolder "c:\TMP\PowerShell\Organisational Docs" -ExportMetadata -ExportMetadataFile "c:\TMP\PowerShell\metadata_OrganisationalDocs.xlsx"
that should search for all the documents and pass in the pipeline to export to export each one individually. If you wanted even more logging you could capture the search to a variable and then use foreach to manually export each file.
Not sure the -Slow is needed but it usually is on these.
Since it's retrieving all the documents this will make powershell take a big chunck of memory and run slower than the regular export.
Ian, I forgot that I wrote a simple script to check for "long paths". You can try it and see if that helps you determine which paths are too long. "Too long" is set by the variable "$MaxLength" in the script, so you might want to change it to something more realistic like 260, the value I used (110), was just for testing the script.
## Script to find folder paths longer than a specific length.
## Not elaborate, but it works!
$AllFolders = Get-PWFolders -Slow
$MaxLength = 110
$line = "Folders longer than " + $MaxLength + " characters!"
$total = 0
foreach ($folder in $AllFolders)
if ($folder.FullPath.Length -gt $MaxLength)
$line = "Found " + $total + " out of " + $AllFolders.Count + " Folders that are longer than " + $MaxLength + " characters!"
As for which are causing you errors, you might try using a try/catch block. You will need to change the default error action to continue.
This is great. Many
Many Thanks I will give it a try