Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Copy List to CSV
    • Sign In

    • State Not Answered
    • Replies 9 replies
    • Subscribers 66 subscribers
    • Views 406 views
    • Users 0 members are here
    • powershell
    • cmdlet
    • copy list to

    Copy List to CSV

    Jutin Jussal
    Offline Jutin Jussal 8 months ago

    Is there a cmdlet to copy list to CSV?

    • Sign in to reply
    • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Thu, Jan 26 2023 4:33 PM

      A list of what? There isn't a single cmdlet to do it, but if you get a set of objects you can use Export-CSV to export the object info to a CSV file. For example:

      Get-PWDocumentsBySearch -FolderPath 'Path\to\folder' | Select FullPath,CreateDate,FileUpdateDate | Export-CSV -Path 'c:\csv\csv_file.csv'

      Get-PWDocumentsBySearch retrieves info on documents

      Select picks which data you want to export

      export creates the CSV file

      the | between commands means "send output from the previous command to the next command"

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Jutin Jussal
      0 Offline Jutin Jussal Thu, Jan 26 2023 6:18 PM in reply to Kevin van Haaren

      Thank you Kevin. What we're trying to do is get the results from a Saved Search over to a CSV and usually in PW we can just right click and do a copy list to. In PowerShell I am trying the following command and it just hangs.

      get-pwdocumentsbysearch -SearchName 'Documents checked out more than 7 days' | Export-CSV 'C:\Saved_Search_Export\results.csv'

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Fri, Jan 27 2023 7:09 PM in reply to Jutin Jussal

      If you run just the Get-PWDocumentsBySearch by itself does it return documents?

      is the search in your SearchName a global search in the datasource, or is it a search in a Work Area folder? For a global search in a Work Area you need to specify the SearchName as 'path\to\workarea\searchname'

      if it's a personal search instead of a global one you'll need to add the -Personal option too

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Jutin Jussal
      0 Offline Jutin Jussal Mon, Jan 30 2023 6:47 PM in reply to Kevin van Haaren

      Thanks Kevin, this worked, I am now getting results as expected but I am just getting way more information than needed. I will keep trying different cmdlets to see if one of them can narrow down the results to just show what I need from the Saved Search. 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Mon, Jan 30 2023 7:36 PM in reply to Jutin Jussal

      You can also use the Where command to limit which objects you're seeing. If you can do it in the saved search it will be faster to do so, but if you want to do something that isn't possible (or is hard to setup) in a saved search Where can help out.

      For example if you want files that have been updated by a member of a set of users, instead just one user, setting up all those OR searches sucks so you can do:

      Get-PWDocumentsBySearch -SearchName 'path\to\search' -Slow | Where { $_.FileUpdater.UserName -in @('user1','user2','user3') } | Export-Csv

       

      • 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