Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding and removing extensionattribute to AD object

I'm using powershell to modify some AD extensionattribute.

This is my code to add an extensionattribute

Set-ADUser -Identity "anyUser" -Add @{extensionAttribute4="myString"}

It works, but how can I remove the same extensionattribute? I can't find anything similar to -remove.

like image 206
Naigel Avatar asked Apr 04 '13 09:04

Naigel


People also ask

What is Extensionattribute AD?

You can use the Extension attributes or create a new attribute in the AD schema (i.e., the blueprint of all objects and attributes that you can create in the AD). Each object in the AD has Extension attributes. The system doesn't use these attributes; Microsoft provides them so that you don't have to create them.

How do I add an extension to AD attributes?

To create a new Attribute:Choose File > Add or Remove Snap-ins then select the Active Directory Schema option. Double-click or click Add then click OK to load the Snap-in. Once the Snap-in has been loaded, expand this out, right-click on the Attributes entry then select Create Attribute... to continue.

How do you remove an AD attribute?

If you want to clear attribute value for ad user account, use AdUser -Clear parameter to clear attribute value. In the above PowerShell script, Get-Aduser cmdlet get user from specified OU and pass the output to the second command. The second command uses Set-ADUser to clear attribute values.

Does Azure AD have extension attributes?

Extension attributes offer a convenient way to extend your Azure AD directory with new attributes that you can use to store attribute values for objects in your directory. You can attach an extension attribute to the following object types: users. tenant details.


2 Answers

You could try using the -Clear parameter

Example:-Clear Attribute1LDAPDisplayName, Attribute2LDAPDisplayName

http://technet.microsoft.com/en-us/library/ee617215.aspx

like image 57
Richard Avatar answered Oct 19 '22 04:10

Richard


I used the following today - It works!

Add a value to an extensionAttribute

 $ThisUser = Get-ADUser -Identity $User -Properties extensionAttribute1
    Set-ADUser –Identity $ThisUser -add @{"extensionattribute1"="MyString"}

Remove a value from an extensionAttribute

  $ThisUser = Get-ADUser -Identity $User -Properties extensionAttribute1
  Set-ADUser –Identity $ThisUser -Clear "extensionattribute1" 
like image 42
Jim Henderson Avatar answered Oct 19 '22 04:10

Jim Henderson