Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell to place AD attributes

Posted on 2014-03-28
3
Medium Priority
?
156 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 1500 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 1500 total points
ID: 39962961
set-Aduser -Identity $User
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

963 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