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
    Parents
    • 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 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
    • Brian Flaherty
      0 Offline Brian Flaherty Tue, Apr 14 2020 1:46 PM in reply to Lonnie Frater

      Please explain what it is you are attempting to do? I am not understanding your comment " I don't believe I could input results of a search but could only address folder that inhibited me using it.".   

      If you do not want the audit trail records included, I would suggest submitting a new post requesting the addition of a -NoAuditTrail parameter. If it is beneficial to others as well, it could be added to the Export-PWDocuments cmdlet.    

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Lonnie Frater
      0 Offline Lonnie Frater Tue, Apr 14 2020 8:08 PM in reply to Brian Flaherty

      Hi Brian,

      My initial post, I am new at this so maybe there is another way, however company policy requires us to export a copy of PW data to be backed up locally, hence the requirement to regularly export documents changed in the last x days.

      So at present I came up with script that searched for documents as below for example

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

      Then using Splat InputDocuments = $pwDocumentsToExport etc. then Export-PWDocuments etc. . This works ok but junks up the audit trail listing in PW with export details which users don't need to see and have to scroll through to actually find an event. So it seems with Export-PWDocuments I don't have the -NoAuditTrail parameter.

      Hence looked at Export-PWDocumentsToArchive but I could not use the input $pwDocumentsToExport but rather only have parameter -ProjectWiseFolder to specify a location and -FileUpdatedAfter / Before parameter are not valid for this cmdlet.

      Maybe there is another way? I will start a new post as you suggest, however you may wish to make comment if I have this correct, or I am missing something.

      Thanks in advance

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Wed, Apr 15 2020 3:43 AM in reply to Lonnie Frater

      So, you want to suppress the comment being added to the audit trail stating the document was exported, correct? No need for an additional post.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Lonnie Frater
      0 Offline Lonnie Frater Wed, Apr 15 2020 3:57 AM in reply to Brian Flaherty

      Yes Brian correct.

      Additionally ideally I would like to be able to create a log file of what is exported also. I seem to be able to can capture the transactions just using Start-Transcript with the datasource, export paths etc but not the actual copy Export-PWDocuments

      For example from PowerShell - Copied out 'C:\Export\17053\4 Drawings\4.3 Models\A30\Structural\Test Doc.txt' (Did not exist on disk) but I have not found a way to capture this detail.

      Thanks

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Lonnie Frater
      0 Offline Lonnie Frater Wed, Apr 15 2020 3:57 AM in reply to Brian Flaherty

      Yes Brian correct.

      Additionally ideally I would like to be able to create a log file of what is exported also. I seem to be able to can capture the transactions just using Start-Transcript with the datasource, export paths etc but not the actual copy Export-PWDocuments

      For example from PowerShell - Copied out 'C:\Export\17053\4 Drawings\4.3 Models\A30\Structural\Test Doc.txt' (Did not exist on disk) but I have not found a way to capture this detail.

      Thanks

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    No Data

    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