1

When running a script to update the addresses of users from a csv file. I found that when trying to apply the City value (listed as lower case L in the attribute editor) instead it would update the value of userWorkstations (a feature that restricts users to only log into workstations with the hostname matching the string).

So after unblocking all the users, I researched it further.

Running the following code on a test user gets the following results in powershell on the Active Directory Server.

PS C:\Windows\system32> Get-ADUser -Identity TestUser -Properties Name,City,UserWorkStations | Format-Table Name,City,UserWorkStations

Name                City                UserWorkStations
----                ----                ----------------
Test Test                    


PS C:\Windows\system32> Set-ADUser -Identity TestUser -l TESTVALUE

PS C:\Windows\system32> Get-ADUser -Identity TestUser -Properties Name,City,UserWorkStations | Format-Table Name,City,UserWorkStations

Name                City                UserWorkStations
----                ----                ----------------
Test Test                               TESTVALUE

I ended up using the friendly name -City to update the city field on the address tab of the Users.

Can anyone explain why updating this specific attribute manages to apply itself to the wrong attribute?

2

2 Answers 2

4

Switch -l for Set-ADUser is expanded to -LogonWorkstations that is why you get it filled.

2

If you want to use the actual attribute name, use the -Add or -Replace switches:

Set-AdUser -Identity "CN=SomeUser,OU=Users,OU=HQ,DC=contoso,DC=com" -Replace @{l="CityName"}

https://docs.microsoft.com/en-us/powershell/module/addsadministration/set-aduser

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .