Need Help Select-Object Argument

Welcome Forums General PowerShell Q&A Need Help Select-Object Argument

Viewing 6 reply threads
  • Author
    Posts
    • #245108
      Participant
      Topics: 9
      Replies: 19
      Points: 95
      Rank: Member

      How do I build the select statement argument so I can call select dynamically?

      When I reference my variable in the select statement it concatenates into a single string – (expansion?)
      If I call the variable spearately then copy and paste the output of the variable I get what I need.

      [/crayon]
    • #245114
      Senior Moderator
      Topics: 9
      Replies: 1309
      Points: 4,781
      Helping Hand
      Rank: Community Hero

      Above expressions gives a string here which has commas and treated whole as a property name to select. So here you just need to split it by comma which will give you an array and each item in the array will be treated as property to select as -Property will accept array of strings.

    • #245126
      Participant
      Topics: 9
      Replies: 19
      Points: 95
      Rank: Member

      So close!

      Thanks for the response kvprasoon!

      Unfortunately I get empty properties/columns using this method – columns are correct but no data whereas if I type it manually I get data back

    • #245150
      Participant
      Topics: 9
      Replies: 19
      Points: 95
      Rank: Member

      Here’s what I see

      [/crayon]

      Here’s what I was hoping for:

      [/crayon]
    • #245153
      Participant
      Topics: 9
      Replies: 19
      Points: 95
      Rank: Member

      $import | select -Property ($list.Substring(0,($sb.Length)-1) -split ',').replace('"','')

      This is it!!

      Why does that work, when if typing it out I would need to add the quotes?

    • #245171
      Participant
      Topics: 7
      Replies: 557
      Points: 2,122
      Helping Hand
      Rank: Community Hero

      Why are you collecting the role names like this?

    • #245178
      Participant
      Topics: 9
      Replies: 19
      Points: 95
      Rank: Member

      Most natural way for me to do so/Lack of experience doing it other ways 😀

      Huge thanks to everyone here for all the knowledge/help.

      As far as Netsuite (system it comes from) the output is a csv, where properties are (first two are always the same)
      Category,Permission,Role1,Role2,Role3, etc.

      Separately I have a csv of users where their role(s) are included.

      What did you have in mind, Doug?

Viewing 6 reply threads
  • You must be logged in to reply to this topic.