Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Export from ProjectWise
    • Sign In

    • State Not Answered
    • Replies 9 replies
    • Subscribers 65 subscribers
    • Views 1737 views
    • Users 0 members are here

    Export from ProjectWise

    Lonnie Frater
    Offline Lonnie Frater over 3 years ago

    Hey All,

    Clearly I am new at this so don't laugh but looking for some assistance with export scrip. I have played around and done a basic export with powershell to a local system drive but want to make it a little more sophisticated and resolve a couple of things.

    I used the below code simply searching and exporting on a file extension. However I would like to be able to search for any file modified in the last x days, but don't know how to go about it. Tried a few things but have not been successful in achieving what I want.

    Additionally when I export  is it possible that the data retains the original "data modified" for PW? At present it simply shows the time exported as "date modified" in Windows.

    #Credentials - change to suit
     $Datasource = 'xxx.bentley.com:xxx';
      
     
     #Open Connection 
     New-PWLogin -DatasourceName $Datasource -UserName "PWxx" -Password (ConvertTo-SecureString -String xxxxx -AsPlainText -Force) -Verbose
     
     # Specify the folder to export
     $FoldersToExport =  @("\17053\")
     
     # Local folder to export documents to.
     $ExportFolder = 'C:\Export'
     
     Foreach($FolderToExport in $FoldersToExport){
     $LocalExportLocation = 'C:\Export'
     #Set export location
     write-host 'PW Folder: ' $FolderToExport
     write-host 'Local Folder: ' $LocalExportLocation
    
     # Populate variable with ProjectWise document objects to be exported.
     $pwDocumentsToExport =  Get-PWDocumentsBySearch -FolderPath $FolderToExport -filename '%.txt'
     
     # Show the number of documents being exported.
     $pwDocumentsToExport.Count
     
     # Show list of document names.
     $pwDocumentsToExport | Select-Object Name
     
     # Local folder to export documents to.
     $ExportFolder = 'C:\Export'
      
     # Open the local folder to see content.
     # Explorer $exportFolder
     }
     # Export documents to local folder.
     $Splat_Export = @{
        InputDocuments = $pwDocumentsToExport
        OutputFolder = $LocalExportLocation
     }
     $Results = Export-PWDocuments @Splat_Export -Verbose
     
     #Cleanup
     Remove-Variable Datasource
     Remove-Variable FoldersToExport
     Remove-Variable ExportFolder
     Remove-Variable FolderToExport
     Remove-Variable LocalExportLocation

    Any help would be appreciated, thanks in advance

    • Sign in to reply
    • Cancel
    • Lonnie Frater
      0 Offline Lonnie Frater Mon, Apr 13 2020 9:16 PM

      Ill answer my own question, persistence found a solution.

      Apparently a better/quicker search according to help and i made work . Would still like to know if there is a solution for "Date Modified" to remain the same when exported.

      $pwDocumentsToExport = Get-PWDocumentsBySearchWithReturnColumns -FolderPath $FolderToExport -FileUpdatedAfter 2020-03-05 -FileUpdatedBefore 2020-04-13

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert McMillan
      0 Offline Robert McMillan Mon, Apr 13 2020 10:05 PM in reply to Lonnie Frater

      Hi Lonnie, I've found that the Windows date modified gets updated to match the original ProjectWise date modified if you export the documents a second time. It looks to be a bug that it's not updated during the first export. As a workaround on line 41 of your original code I would repeat the export process to update the Windows modified date.

      $null = Export-PWDocuments @Splat_Export -Verbose

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Lonnie Frater
      0 Offline Lonnie Frater Mon, Apr 13 2020 11:55 PM in reply to Robert McMillan

      Hi Robert,

      Thanks for taking the time to respond, appreciated.

      I applied your suggestion and as you indicated this appears on the second pass to move the date modified from 'now' to the original, only there is a + 11 hour offset? i.e. original file in PW Explorer displays as 12/04/2020 5:51:57 PM and when copied with the second pass windows displays as 13/04/2020 4:53 PM?

      I assume this is a regional thing between local system (+8) and cloud server +10 at the time file was created (or +11 DST) ?? not sure why the additional hour.

      If i rerun the export it does recognise the file to be the same.

      Thanks again

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert McMillan
      0 Offline Robert McMillan Tue, Apr 14 2020 3:33 AM in reply to Lonnie Frater

      Hi Lonnie, do you happen to know what version of ProjectWise server you are running? On versions prior to Update 3.1 (10.00.03.140) ProjectWise displays the local time on the database server as the timestamp while on newer versions if will convert the timestamp it to local time. You can check the server version with the 32-bit PWPS cmdlet Get-PWServerVersion. You could also try using the Export-PWDocuments parameter -ServerIsUTC to see if it changes your output timestamps.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Lonnie Frater
      0 Offline Lonnie Frater Tue, Apr 14 2020 5:08 AM in reply to Robert McMillan

      Hi Robert,

      New cloud instance version 10.00.03.271

      I will experiment with parameter -ServerIsUTC  when I get a few min. 

      Another annoyance factor I discovered is I cannot use -NoAuditTrail or similar. Does anyone know if there is another way to accomplish this? Was looking at Export-PWDocumentsToArchive but there seemed to be other limitations, I don't believe I could input results of a search but could only address folder that inhibited me using it.

      Thanks 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    >

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies