Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Data limit when using "Get-PWDocumentsBySearch" and flag "-Attributes"
    • Sign In

    • State Verified Answer
    • +1 person also asked this people also asked this
    • Replies 12 replies
    • Subscribers 68 subscribers
    • Views 2092 views
    • Users 0 members are here
    • powershell
    • pwps_dab
    • Get-PWDocumentsBySearch
    • ProjectWise PowerShell Modules

    Data limit when using "Get-PWDocumentsBySearch" and flag "-Attributes"

    Edward Ashbolt
    Offline Edward Ashbolt over 3 years ago

    As per the title, has anyone else encountered this? I have found that when performing a document search including attributes, if the search returns a large number of files then processing will stop. The interim measure I have used as a work-around to avoid this is to first return a list of documents, then loop through each document and return the attributes like so:

    $docs = Get-PWDocumentsBySearch -FolderID 24391 -Attributes @{ShareFileTrigger=1}
    
    foreach ($i in $docs)
    {
        $doc = Get-PWDocumentsBySearch -FileName $i.FileName -FolderID $i.ProjectID -JustThisFolder -GetAttributes
    }

    However the above listed code has to perform 2 search operations so there is a significant performance hit due to double handling. Does anyone know of a better solution to this problem? 

    Additionally, is there anywhere that we can view the source code of the pwps_dab cmdlets?

    I'd be interested to see how it is returning the data as it reminds me a lot of an issue that I encountered previously with WScript.Shell.Exec() where if you use StdOut.ReadAll at the end of the process and the TextStream is large enough it will hit a memory limit and stop processing. The solution to that problem was to instead use StdOut.ReadLine() and add each line to a collection for later use; freeing up the StdOut memory for more incoming data:

    Do While Not exec.StdOut.AtEndOfStream
        output.Add exec.StdOut.ReadLine()
    Loop

    If anyone has any suggestions or knowledge on the matter it would be greatly appreciated!
    Thanks,

    Edward

    • Sign in to reply
    • Cancel

    Top Replies

    • Kevin van Haaren
      Offline Kevin van Haaren Tue, Jan 7 2020 6:42 PM in reply to Edward Ashbolt +1
      pwps_dab is not open source. I wrote a script that had to process tens of thousands of files. I had problems but pretty sure it wasn't a stream buffer but just time on the database server. More than…
    • Kevin van Haaren
      Offline Kevin van Haaren Tue, Jan 7 2020 6:45 PM in reply to Edward Ashbolt +1
      Brian - could we get -GetAttributes added to Get-PWDocumentsByGUIDs? (and if you're working in that cmdlet anyway add -GetVersionsToo as well?)
    • Brian Flaherty
      Offline Brian Flaherty Wed, Jan 8 2020 9:47 AM in reply to Edward Ashbolt +1 verified
      Hmmm, when I use the Get-PWDocumentsByGUIDs, it is returning the attributes. take a look at https://github.com/DaveBrumbaugh/MostOfDavesClasses-CSharp-Wrappers-For-ProjectWise
    Parents
    • Glenn Ryan
      0 Offline Glenn Ryan Sat, Jan 11 2020 7:43 AM

      I've found Get-PWDocumentsBySearchWithReturnColumns to be very performant. I use it instead of Get-PWDocumentsBySearch -GetAttributes when I know the column names I want to return ahead of hand. It also has an -Attributes switch, so you can use it like you show above, with a hashtable of attrib/value pairs.

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Glenn Ryan
      0 Offline Glenn Ryan Sat, Jan 11 2020 7:43 AM

      I've found Get-PWDocumentsBySearchWithReturnColumns to be very performant. I use it instead of Get-PWDocumentsBySearch -GetAttributes when I know the column names I want to return ahead of hand. It also has an -Attributes switch, so you can use it like you show above, with a hashtable of attrib/value pairs.

      • Cancel
      • Vote Up +1 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