Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum using where-object to compare ProjectWise userlist
    • Sign In

    • State Suggested Answer
    • Replies 5 replies
    • Answers 1 answer
    • Subscribers 65 subscribers
    • Views 750 views
    • Users 0 members are here

    using where-object to compare ProjectWise userlist

    Stephen Herrick
    Offline Stephen Herrick over 2 years ago

    All,

    im sure this PS 101, but i cant seem to get tjhis to work

    i am reading a excel file, and getting a value, i then want to do a comparison to see if a UserList is created, 

     Get-PWUserLists | where-object {$_.Name -Like $Workbooks[0].Client}

    the "Client" value is Holly

    Tjhe UserList Name is "HollyProjects - All Holly Groups"

    but when i run the line, i dont get any output, so why isn't the -Like statement working.....

    TIA

    Stephen

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Wed, Apr 28 2021 12:36 PM +1
      Try Get-PWUserLists | Where-Object Name -Match $Workbooks[0].Client Ensure the $Workbooks[0].Client is returning what you are expecting. Should be a string value I would guess.
    • Brandon Williams
      Offline Brandon Williams Wed, Apr 28 2021 12:47 PM +1
      I would also try Get-PWUserLists | where-object {$_.Name -Like "*$($Workbooks[0].Client)*"}
    Parents
    • Brandon Williams
      0 Offline Brandon Williams Wed, Apr 28 2021 12:47 PM

      I would also try Get-PWUserLists | where-object {$_.Name -Like "*$($Workbooks[0].Client)*"}

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Wed, Apr 28 2021 12:59 PM in reply to Brandon Williams

      One thing to note, if you use the -Match, it eliminates the need for the wildcards. Slight smile

      Multiple ways to accomplish the same thing.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brandon Williams
      0 Offline Brandon Williams Wed, Apr 28 2021 1:07 PM in reply to Brian Flaherty

      I have noticed that in the past because I believe -match -notmatch uses regex and -like -notlike is more a wildcard expression.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Stephen Herrick
      0 Offline Stephen Herrick Wed, Apr 28 2021 2:10 PM in reply to Brian Flaherty

      that was the trick, i only assumed match implied exactly the text,  good to know, 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    Reply
    • Stephen Herrick
      0 Offline Stephen Herrick Wed, Apr 28 2021 2:10 PM in reply to Brian Flaherty

      that was the trick, i only assumed match implied exactly the text,  good to know, 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject 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