ActiveDirectory module: Format output of get-aduser

Welcome Forums General PowerShell Q&A ActiveDirectory module: Format output of get-aduser

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 weeks, 4 days ago.

  • Author
    Posts
  • #126042

    Participant
    Points: 14
    Rank: Member

    Hi,

    if  users have a jpegPhoto defined in Active Directory, the output of

    get-aduser MyUser -properties *

    is becoming unwieldy since the full binary data of the picture is printed out. In contrast, the thumbnailPhoto property only shows the first 8 bytes of the respective picture. How can I tell PowerShell to reduce the output of the jpegPhoto property to 8 bytes as well?

    Thanks a lot for your help.

     

    Best regards,

    Detlev

  • #126086

    Participant
    Points: 304
    Helping Hand
    Rank: Contributor

    Your first option is to not use -Properties *. Personally, I only use that on 1 object to see the properties I need and then define the exact properties. Another option is:

    Get-ADUser MyUser -properties * | Select * -ExcludeProperty jpegPhoto 
    

    As far as how an attribute is concatenated, that is handled with a Type definition in a PS1XML file. Typically, this is done in a module when you want to display cleaner object information versus one output like this, but you could still define a custom display for Get-ADUser. Take look at these if you'd like to research further:

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-6

    Formatting object output in PowerShell with Format.ps1xml files

    • #126225

      Participant
      Points: 14
      Rank: Member

      Thank you very much! This information was very helpful. Unfortunately, I'm still stuck. I worked through the documentation of the Format.ps1xml and the Types.ps1xml and I think I have come to a reasonable understanding of how this is supposed to work.  However, I still can't find where the formatting of the jpegPhoto property is defined.

      It seems the type returned by get-aduser is Microsoft.ActiveDirectory.Management.ADUser

      get-aduser * | get-member
      
      # TypeName: Microsoft.ActiveDirectory.Management.ADUser
      get-command get-aduser | select * 
      # OutputType          : {}

      which in ActiveDirectory.Types.ps1xml seems to get mapped to a type adapter (replaced XML brackets with square brackets):

      [Type] 
      [Name]Microsoft.ActiveDirectory.Management.ADUser[/Name]
      [TypeAdapter] [TypeName]Microsoft.ActiveDirectory.Management.ADEntityAdapter[/TypeName] [/TypeAdapter]
      [/Type]

      Here I'm stuck. I could not find where PowerShell is getting the formatting information for this type.

      Does someone have a pointer on how to continue from here? Thanks a lot!

       

       

  • #126258

    Participant
    Points: -15
    Rank: Member

    Hello Seniors

    I have few questions

    1. How do i check user SIP address via Powershell ( For Skype for business )
    2. How do i create/setup SIP address for new user in powershell
    3. How do i check user's hostname or IP address via his Login Credentail in powershell.

    I'm a new user in powersell.

    AD username : Samantha1

    AD Password : Welcome1

    Email address : Samantha1@varadan.com

    Please provide me best solution..

     

     

     

You must be logged in to reply to this topic.