GET-ADUSER output issue

Welcome Forums General PowerShell Q&A GET-ADUSER output issue

Viewing 5 reply threads
  • Author
    Posts
    • #187072
      Participant
      Topics: 18
      Replies: 62
      Points: 300
      Rank: Contributor

      Run this command

      $sname = get-aduser $sam -properties * | select surname

      Results is

      surname

      ——-

      smith

      This is an object surname ______ smith  how to output just smith?

      I need to feed this to another command and the surname ____ give the command a problem.

       

    • #187078
      Participant
      Topics: 8
      Replies: 1247
      Points: 910
      Helping Hand
      Rank: Major Contributor

      To get the string, you can use -ExpandProperty so that $sname = smith:

      $sname = get-aduser $sam -properties * | select -ExpandProperty surname

    • #187096
      js
      Participant
      Topics: 26
      Replies: 702
      Points: 1,798
      Helping Hand
      Rank: Community Hero

      Probably the most common powershell question.

    • #187243
      Participant
      Topics: 18
      Replies: 62
      Points: 300
      Rank: Contributor

      That worked great

      Thank you

       

      This can be marked resolved

       

    • #187279
      Participant
      Topics: 6
      Replies: 108
      Points: 299
      Helping Hand
      Rank: Contributor

      Or reference the property:

      (get-aduser user1 | select Surname).Surname
    • #187288
      js
      Participant
      Topics: 26
      Replies: 702
      Points: 1,798
      Helping Hand
      Rank: Community Hero
      (get-aduser user1).surname
      get-aduser | % surname
      
Viewing 5 reply threads
  • You must be logged in to reply to this topic.