Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell to place AD attributes

Posted on 2014-03-28
3
Medium Priority
?
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

722 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