How to update every single Active Directory User Attributes with Powershell – Part 1

From time to time, I always struggle a little, on how to update specific AD Attributes or I am not sure what is the correct property Name. So this should be a good list, of “all” Active Directory User Attributes, and how you can Update, Change, Set or Clear with PowerShell. So I have created a script of how to set, modify, or clear custom attributes in Active Directory with PowerShell

Starting with the Blog Idea is thought I will go through each Attribute on the “Attribute Editor” Tab. Very quickly I came to the conclusion to limit the List a little, as there are several attributes where it makes no sense to update them through PowerShell. So this list is huge, but not a complete Attribute List.

All 4 Parts are here

How to update every single Active Directory User Attributes with Powershell – Part 1 – TechGuy
How to update every single Active Directory User Attributes with Powershell – Part 2 – TechGuy
How to update every single Active Directory User Attributes with Powershell – Part 3 – TechGuy
How to update every single Active Directory User Attributes with Powershell – Part 4 – TechGuy

A Full documented List from Microsoft is here: All Attributes – Win32 apps | Microsoft Docs


So I have created a Test User in my Active Directory with the Name “Michael Techguy” and the UPN and SamAccountName TecMi

The List

accountExpires

GUI

TAB: Account / Account Expires

PowerShell

#SET Values
Set-ADUser -Identity TecMi -AccountExpirationDate (Get-Date).AddDays(5)

#CLEAR Value
Set-ADUser -Identity TecMi -AccountExpirationDate $null

#READ Value
Get-ADUser -Identity TecMi -Properties AccountExpirationDate | Select-Object -Property AccountExpirationDate


assistant

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -add @{assistant=@("CN=Michael Seid,DC=au2mator,DC=local")}

#CLEAR Value
Set-ADUser -Identity TecMi -Clear assistant

#READ Value
Get-ADUser -Identity TecMi -Properties assistant | Select-Object -Property assistant

c

This Property can be set independently, but see this Post for more Details Updating the Country Field in Active Directory – AdamFowlerIT.com

GUI

TAB: Address / Country/region

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Country AT
Set-ADUser -Identity TecMi -Replace @{c="AT";co="Austria";countrycode=40}
#https://www.iso.org/obp/ui/#search/code/

#CLEAR Value
Set-ADUser -Identity TecMi -Clear c

#READ Value
Get-ADUser -Identity TecMi -Properties c | Select-Object -Property c

carLicense

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -add @{carLicense=@("LL123AB")}

#CLEAR Value
Set-ADUser -Identity TecMi -Clear carLicense

#READ Value
Get-ADUser -Identity TecMi -Properties carLicense | Select-Object -Property carLicense

co

See Property “c” for details

GUI

TAB: Address / Country/region

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{c="AT";co="Austria";countrycode=40}
#https://www.iso.org/obp/ui/#search/code/

#CLEAR Value
Set-ADUser -Identity TecMi -Clear co

#READ Value
Get-ADUser -Identity TecMi -Properties co | Select-Object -Property co

company

GUI

TAB: Organizaton / Company

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Company "au2mator"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear company

#READ Value
Get-ADUser -Identity TecMi -Properties company | Select-Object -Property company

countryCode

See Property “c” for details

GUI

TAB: Address / Country/region

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{c="AT";co="Austria";countrycode=40}
#https://www.iso.org/obp/ui/#search/code/

#CLEAR Value
Set-ADUser -Identity TecMi -Clear co

#READ Value
Get-ADUser -Identity TecMi -Properties co | Select-Object -Property co

department

GUI

TAB: Organization/ Department

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Department "CEO"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear Department

#READ Value
Get-ADUser -Identity TecMi -Properties Department | Select-Object -Property Department

description

GUI

TAB: General / Description

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Description "This is a Descripion"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear Description

#READ Value
Get-ADUser -Identity TecMi -Properties Description | Select-Object -Property Description

displayname

GUI

TAB: General/ Display name:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -DisplayName "Techguy Michael"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear DisplayName

#READ Value
Get-ADUser -Identity TecMi -Properties DisplayName | Select-Object -Property DisplayName

division

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Division "My Division"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear division

#READ Value
Get-ADUser -Identity TecMi -Properties division | Select-Object -Property division

employeeID

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -EmployeeID "123455"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear employeeID

#READ Value
Get-ADUser -Identity TecMi -Properties employeeID | Select-Object -Property employeeID

employeeNumber

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -EmployeeNumber "123455"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear employeeNumber

#READ Value
Get-ADUser -Identity TecMi -Properties employeeNumber | Select-Object -Property employeeNumber

employeeType

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{employeeType="student"}

#CLEAR Value
Set-ADUser -Identity TecMi -Clear employeeType

#READ Value
Get-ADUser -Identity TecMi -Properties employeeType | Select-Object -Property employeeType

facsimileTelephoneNumber

GUI

TAB: Telephones / Fax:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{facsimileTelephoneNumber="0165772345"}
Set-ADUser -Identity TecMi -Fax "012345"

#CLEAR Value
Set-ADUser -Identity TecMi -Clear facsimileTelephoneNumber

#READ Value
Get-ADUser -Identity TecMi -Properties facsimileTelephoneNumber | Select-Object -Property facsimileTelephoneNumber

GitHub

Here is the GitHub Repo: Seidlm/Active-Directory (github.com)

Michael Seidl, aka Techguy
au2mate, everything

3 thoughts on “How to update every single Active Directory User Attributes with Powershell – Part 1”

  1. Pingback: How to update every single Active Directory User Attributes with Powershell - Part 2 - TechGuy

  2. Pingback: How to update every single Active Directory User Attributes with Powershell - Part 3 - TechGuy

  3. Pingback: How to update every single Active Directory User Attributes with Powershell - Part 4 - TechGuy

Leave a Comment

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

*