Solved

Powershell to place AD attributes

Posted on 2014-03-28
3
151 Views
Last Modified: 2014-04-03
I am looking to replace incorrect information in AD using Powershell. For example, I ve recently added information within AD like Telephone numbers or Title but some of them are incorrect. Now I need to re-run the script to replace it the correct info but after running it wouldn't update.
0
Comment
Question by:adigu1t
  • 2
3 Comments
 
LVL 29

Assisted Solution

by:becraig
becraig earned 500 total points
ID: 39962904
Import-module ActiveDirectory
Import-CSV "c:\path-to-csv\file.csv" | % {
Set-ADUser -identity $_.SamAccountName  -HomePhone $_.Homephone -Title $_.title
}
                           
                              

Open in new window

             

This assumes you have a csv with headers matching

SamAccountName, Homephone, title
0
 

Author Comment

by:adigu1t
ID: 39962958
Here is my script below:

Import-Module ActiveDirectory

Import-csv -path c:\jmiller\ITpeopledata.csv | Foreach-Object {

$User = $_.sAMAccountName
$OfficePhone = $_.OfficePhone
$Office = $_.Office
$streetAddress = $_.streetAddress
$postalCode = $_.postalCode
$title = $_.title
$department = $_.department
$company = $_.company
$manager = $_.manager
$Division = $_.division
$Status = $_.Status
$mobilephone = " "
$EmployeeID = $_.EmployeeID


set-Aduser $User -mobilephone $mobilephone -streetAddress $streetAddress -postalCode $postalCode -title $title -department $department -company $company -manager $manager -officephone $_.officephone -office $_.office -city $_.city -division $_.division -EmployeeID $_.EmployeeID
0
 
LVL 29

Accepted Solution

by:
becraig earned 500 total points
ID: 39962961
set-Aduser -Identity $User
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question