Bize Ulaşın / Contact Us

powershell logo

How to add or remove extensionAttribute of an AD User object

11 / 08 / 2015 by Active Directory, PowerShell 1 Yorum / Comment

I would like to share some simple PowerShell commands, to show how to add or remove extensionAttribute of an AD User object

Import AD Module First

[PS] C:\>import-module ActiveDirectory

To get current value

[PS] C:\>Get-ADUser -Identity firstuser -Properties extensionAttribute12

DistinguishedName : CN=First User,OU=TempTest,DC=infralib,DC=com
Enabled : False
GivenName : First
Name : First User
ObjectClass : user
ObjectGUID : 471ed3b9-27d8-4fce-8766-7be5fe790994
SamAccountName : firstuser
SID : S-1-5-21-1060284298-1993962763-2146565907-19317
Surname : User
UserPrincipalName : [email protected]

To add a value

[PS] C:\>set-ADUser -Identity firstuser -Add @{extensionAttribute12="20012001"}

To check the result

[PS] C:\>Get-ADUser -Identity firstuser -Properties extensionAttribute12

DistinguishedName : CN=First User,OU=TempTest,DC=infralib.com,DC=com
Enabled : False
extensionAttribute12 : 20012001
GivenName : First
Name : First User
ObjectClass : user
ObjectGUID : 471ed3b9-27d8-4fce-8766-7be5fe790994
SamAccountName : firstuser
SID : S-1-5-21-1060284298-1993962763-2146565907-19317
Surname : User
UserPrincipalName : [email protected]

To remove / clear

[PS] C:\>set-ADUser -Identity firstuser -Clear "extensionAttribute12"

To check the result

[PS] C:\>Get-ADUser -Identity firstuser -Properties extensionAttribute12

DistinguishedName : CN=First User,OU=TempTest,DC=infralib.com,DC=com
Enabled : False
GivenName : First
Name : First User
ObjectClass : user
ObjectGUID : 471ed3b9-27d8-4fce-8766-7be5fe790994
SamAccountName : firstuser
SID : S-1-5-21-1060284298-1993962763-2146565907-19317
Surname : User
UserPrincipalName : [email protected]

You can visit links below to find out more information about Get-ADUser and Set-ADUser PS commands.

TechNet Get-ADUser

TechNet Set-ADUser


One comment on “How to add or remove extensionAttribute of an AD User object

  1. on August 13, 2015
    Jason White says:

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

*

Kontrol / Control * Time limit is exhausted. Please reload CAPTCHA.