Solved

Powershell to place AD attributes

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

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 28

Accepted Solution

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
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…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

747 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

14 Experts available now in Live!

Get 1:1 Help Now