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

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

Please see other Parts here

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

The List


preferredLanguage

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi  -Replace @{preferredLanguage="DE-AT"}

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

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

primaryGroupID

GUI

TAB: Member Of / Primary Group:

PowerShell

#SET Values
$ADGroup=Get-ADGroup -Identity "Test Primary"
Add-ADGroupMember -Identity $ADGroup.DistinguishedName -Members "TecMi"
$primaryGroupID = $ADGroup.SID -replace @('.+\-','')
Set-ADUser -Identity TecMi -Replace @{'primaryGroupID' = $primaryGroupID} -ErrorAction SilentlyContinue -PassThru 

#CLEAR Value

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

primaryInternationalISDNNumber

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{primaryInternationalISDNNumber="0123456"}

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

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

primaryTelexNumber

GUI

NO

PowerShell

#SET Values
#SET Values
Set-ADUser -Identity TecMi -Replace @{primaryTelexNumber="0123456"}

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

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

profilePath

GUI

TAB: Profile / User profile / Profile path:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -ProfilePath "\\server1\share\User"

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

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

sAMAccountName

GUI

TAB: Account / User logon name (pre-Windows 2000):

PowerShell

#SET Values
Set-ADUser -Identity TecMi -SamAccountName "TecMi2"

#CLEAR Value

#READ Value
Get-ADUser -Identity TecMi2 -Properties SamAccountName | Select-Object -Property SamAccountName


scriptPath

GUI

TAB: Profile / Logon script:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -ScriptPath "\\server1\share\User\logon.bat"

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

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

secretary

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{secretary=@((Get-ADuser -Identity "m.seidl").DistinguishedName)}
Set-ADUser -Identity TecMi -Add  @{secretary=@((Get-ADuser -Identity "HofmeisterJ").DistinguishedName)}
Set-ADUser -Identity TecMi -Remove  @{secretary=@((Get-ADuser -Identity "m.seidl").DistinguishedName)}

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

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

seeAlso

GUI

NO

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Replace @{seeAlso=@((Get-ADuser -Identity "m.seidl").DistinguishedName)}
Set-ADUser -Identity TecMi -Add  @{seeAlso=@((Get-ADuser -Identity "HofmeisterJ").DistinguishedName)}
Set-ADUser -Identity TecMi -Remove  @{seeAlso=@((Get-ADuser -Identity "m.seidl").DistinguishedName)}

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

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

sn

GUI

TAB: General / Last name:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -Surname "Seidl"

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

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

street

GUI

TAB: Address / Street:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -StreetAddress "Wilhelm-Fein-Straße 37"

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

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

telephoneNumber

GUI

TAB: General / Telephone number:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -OfficePhone "+4 364 6 6 465"

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

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

title

GUI

TAB: Organization / Job Title:

PowerShell

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

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

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

userPrincipalName

GUI

TAB: Account / User logon name:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -UserPrincipalName "TecMi@au2mator.local"

#CLEAR Value


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

wWWHomePage

GUI

TAB: General / Web page:

PowerShell

#SET Values
Set-ADUser -Identity TecMi -HomePage "www.au2mator.com"

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

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

GitHub

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

Michael Seidl, aka Techguy
au2mate, everything

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

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

Leave a Comment

Your email address will not be published.

*

%d bloggers like this: