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
.
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.
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.
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.
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.
You could try using the -Clear
parameter
Example:-Clear Attribute1LDAPDisplayName, Attribute2LDAPDisplayName
http://technet.microsoft.com/en-us/library/ee617215.aspx
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With