Clearing AD values

A reader left a comment on this post

I was asked to show how to use the –Clear parameter.

Using the same CSV file this works:

$users = Import-Csv -Path C:\Scripts\adtest.csv                        
# Loop through CSV and update users if the exist in CVS file                        
foreach ($user in $users) {                        
#Search in specified OU and Update existing attributes                        
 Get-ADUser -Filter "SamAccountName -eq '$($user.samaccountname)'" -Properties * -SearchBase "cn=Users,DC=manticore,DC=org" |                        
  Set-ADUser -Clear l, physicalDeliveryOfficeName, division                        

The difference with clear is that you have to use the proper LDAP attribute name – you can find this using ADSIEdit if you don’t know what it is. 

This entry was posted in PowerShell and Active Directory. Bookmark the permalink.

3 Responses to Clearing AD values

  1. Alan says:

    LDAP names… That is the part I missed in my attempt to clear attributes. THANKS so much for the help (again).

  2. Shay Levy says:

    One thing though, there is no need to include a property in order to clear it.

  3. Pingback: AD User Attributes Bulk Modification

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s