Solved

Active Directory PS script to modify attributes from CSV file

Posted on 2013-12-17
4
3,354 Views
Last Modified: 2013-12-17
Hello PS - Experts,

I need help with a seemingly simple Powershell script.

I have a CSV looking like this:
Name,Uid,Gid
jsmith,123456,78910
user2,123457,78910

Open in new window


The script should read the values and select an AD object by logon name and modifying this object's attributes GIDnumber and UIDnumber values with the ones from the CSV.

Thanks in advance!
Helge
0
Comment
Question by:Daniel Helgenberger
[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
4 Comments
 
LVL 3

Expert Comment

by:Detlef001
ID: 39723782
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39724162
What attributes are you looking to change in Active Directory referencing GIDNumber and UIDNumber? Do you want these numbers in the extensionAttribute section for Users Accounts?

Below is the structure of how you can do this. I will still need to know what values you want to modify in AD using the GID/UID columns in your CSV file.

Import-module activedirectory
$ModUsers = import-csv "c:\yourCSVfile.csv"
foreach ($User in $ModUsers) {
$User.Name
$User.Uid
$User.Gid
Set-ADUser -Identity $User.Name -extensionAttribute1 $$User.Uid -extensionAttribute2 $User.Gid
}

Open in new window


Will
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39724185
Here's what I was thinking...
Import-Csv file.csv | ForEach `
{
    $uid = $_.UID
    $gid = $_.GID
    Get-ADUser $_.name | Set-ADUser -replace @{gidnumber=$gid;uidnumber=$uid}
}

Open in new window

0
 
LVL 13

Author Closing Comment

by:Daniel Helgenberger
ID: 39724265
Perfect, footech. Thanks!
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision Office 365 tenants, synchronize your on-premise Active Directory, and implement Single Sign-On.

Question has a verified solution.

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

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

739 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