Adding to the expression

This topic contains 3 replies, has 3 voices, and was last updated by  Scott Windmiller 1 year ago.

  • Author
    Posts
  • #54824

    Scott Windmiller
    Participant

    Really stupid question here that is best explained with an example:

    get-aduser tuser| Select @{n='testname';e={$_.samaccountname}}

    I want to add to the end of the samaccountname like:

    get-aduser tuser| Select @{n='testname';e={$_.samaccountname}"SOMETHINGELSE"}

    I know it's something simple but I just don't know how to format it.

    Just learning here 🙂

    Thanks,
    Scott

  • #54826

    random commandline
    Participant
    @{n='testname';e={"$($_.samaccountname)SOMETHINGELSE"}}
    
  • #54827

    Craig Duff
    Participant

    The part inside the {} will evaluate any code and return the results, so you can use any method for creating and joining strings. One example:

    @{n='testname';e={"$($_.samaccountname)SOMETHINGELSE"}}
  • #54828

    Scott Windmiller
    Participant

    Perfect! I knew it was something simple.

    Thanks for not making me feel stupid...lol

You must be logged in to reply to this topic.