Home > front end >  Set AD users extensionAttibute value using powershell
Set AD users extensionAttibute value using powershell

Time:01-18

I need to change the users extensionAttribute8 value to 1

when I am trying to get the existing value for this attribute using below command, I am getting other values but not the specific attribute value

  • Output Example:
DistinguishedName : AAAAA
Enabled           : True
GivenName         : AAAAA
Name              : AAAAA
ObjectClass       : user
ObjectGUID        : 1ed23b21-afa9-4d2d-9c64-d3278f93af50
SamAccountName    : AAAAAA
SID               : AAAAAA
Surname           : AAAA
UserPrincipalName : AAAAA
 $ThisUser = Get-ADUser -Identity $User -Properties extensionAttribute8
 #   Set-ADUser –Identity $ThisUser -add @{"extensionattribute8"="1"}

Please do let me know what is wrong here. Is there something I am missing

CodePudding user response:

This command is correct and retrieves the user required attribute

Get-ADUser -Identity $User -Properties extensionAttribute8

HOWEVER if the attribute isnt populated it won't be returned.

To set the attribute I use:

Set-ADUser -Identity $User -Replace @{"extensionattribute8"="1"}

Use "Replace" as it will work if the value is already populated rather than Add, which will only add to an already populated value.

  • Related