get-ADuser script doesn't work

Welcome Forums General PowerShell Q&A get-ADuser script doesn't work

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

2 years ago.

  • Author
  • #64344

    Points: 1
    Rank: Member


    I just want to do a very simple thing:

    I want a list of all the users from a specific location. The list should include Name, logonname, email, enbaled or disabled, domain.

    I got everything apart from the domain.

    What I have so far:

    Get-ADUser -Filter 'physicaldeliveryofficename -eq "XXX"'| Select-Object name,SamAccountName,Userprincipalname,enabled

    for some reason I had to get the emailadress via the principalusername Select-object [...],mail,[...] did not work.

    I tried to select DC, domain, server non of this works.

    Thank you for your help!!

  • #64365

    Points: 24
    Team Member
    Rank: Member

    Get-ADUser doesn't return all user object attributes by default.

    Get-ADuser -Filter '...' -Properties name, mail, samAccountName, userPrincipalName, enabled | ...
  • #64446

    Points: -11
    Rank: Member


    If you use -filter with non default return attributes you'll need to add it into -properties


  • #64501

    Points: 1
    Rank: Member

    thanks guys that really helped.

    Now it works the way I want it to 🙂

The topic ‘get-ADuser script doesn't work’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort