Solved

Powershell to place AD attributes

Posted on 2014-03-28
3
149 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

To effectively work with Diskpart on a Server Core, it is necessary to write some small batch script's, because you can't execute diskpart in a remote powershell session. To get startet, place the Diskpart batch script's into a share on your loca…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now