Get-AdUser and city

Rob Delbridge 96 Reputation points
2021-05-17T14:31:32.24+00:00

Hello,

We needed to set the city for our users and noticed that the -l can be used as a alias for -city.

For example if you run

get-aduser User.Name -Properties l,logonworkstations

The city will be displayed.

So last week changed city for all our users using the -l alias, shortly after we had a call where we found users users couldn't log on.

After checking their AD account we noticed their LogonWorkStations had been set with their city.

We quickly reversed our change but noticed that if you use:

get-aduser User.Name | set-aduser -l "NEW SITE" 

Then "LogonWorkstations" will be set with "New Site"

What on earth is happening? Is -l different for Ge-Aduser and set-Aduser??

Is this just our domain?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Rob Delbridge 96 Reputation points
    2021-05-18T07:43:44.627+00:00

    Thanks Ian, I'm unable to see where -l for logonworkstations is documented.

    To me this seems like a mistake? So l is used for different things for get and set?


2 additional answers

Sort by: Most helpful
  1. Anonymous
    2021-05-18T02:07:52.69+00:00

    Hi,

    The "-l" parameter is short for "-LogonWorkstations" in Set-ADUser and "-LDAPFilter" in Get-ADUser . To change the "l" attribute you should use the "-City" parameter. The "l" in Get-ADUser $username -Properties l,logonworkstations is the value accepted by the "-Properties" parameter.

    https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-aduser
    https://learn.microsoft.com/en-us/powershell/module/activedirectory/set-aduser

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Andreas Baumgarten 123.5K Reputation points MVP Volunteer Moderator
    2021-05-18T08:26:30.977+00:00

    Maybe this helps:
    https://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx

    City is the Get-ADuser property and l is the equivalent LDAP DisplayName/Attribute

    The LDAP attribute l is defined in RFC2256 - 5.8
    https://datatracker.ietf.org/doc/html/rfc2256#section-5.8

    I wasn't able to find -l as the short/alias for -LogonWorkStations related to the Set-ADUser as well.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.