question

robbyde-5755 avatar image
0 Votes"
robbyde-5755 asked IanXue-MSFT commented

Get-AdUser and city

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-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

robbyde-5755 avatar image
0 Votes"
robbyde-5755 answered IanXue-MSFT commented

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?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The parameters of a cmdlet only need to be able to be distinguished from others. As the "-logonworkstations" parameter is the only parameter of Set-ADUser that starts with "l", you can use '-l', '-lo', '-log' and so on.

0 Votes 0 ·
IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

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://docs.microsoft.com/en-us/powershell/module/activedirectory/get-aduser
https://docs.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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered AndreasBaumgarten edited

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



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.