Skip to content

Instantly share code, notes, and snippets.

@kbhunut
Created April 5, 2020 17:14
Show Gist options
  • Save kbhunut/da20095555c951b92a7face184798bbd to your computer and use it in GitHub Desktop.
Save kbhunut/da20095555c951b92a7face184798bbd to your computer and use it in GitHub Desktop.
Update AD User Object Information
# First you need RSAT tool with Active Directory Powersell Module installed on your local machine
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/?view=win10-ps
# Get user in AD
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-aduser?view=win10-ps
Get-ADuser [email protected]
# Set info for user in AD
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/set-aduser?view=win10-ps
Get-ADuser [email protected] | Set-ADUser -OfficePhone "555-555-1234" -Manager (Get-ADuser [email protected])
# Bulk via CSV
# CSV Header: UserPrincipalName, DisplayName, Description, Office, Telephone, JobTitle, Company, Department, ManagerUPN, Mobile, IPPhone, Street, City, State, Zip
Import-CSV ./update_ad_users.csv | Foreach {
$arguments = @{
DisplayName = $_.DisplayName
Description = $_.Description
Office = $_.Office
OfficePhone = $_.Telephone
Title = $_.JobTitle
Company = $_.Company
Department = $_.Department
Manager = (Get-ADUser $_.ManagerUPN)
MobilePhone = $_.Mobile
StreetAddress = $_.Street
City = $_.City
State = $_.State
PostalCode = $_.Zip
}
Get-ADUser $_.UserPrincipalName | Set-ADUser @arguments
# IPPhone does not have an argument in Set-AdUser...You will need to do it this way
Get-ADUser $_.UserPrincipalName | Set-ADUser -Replace @{ipPhone=$_.IPPhone}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment