Solved

Active Directory PS script to modify attributes from CSV file

Posted on 2013-12-17
4
3,218 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
4 Comments
 
LVL 3

Expert Comment

by:Detlef001
Comment Utility
0
 
LVL 53

Expert Comment

by:Will Szymkowski
Comment Utility
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 39

Accepted Solution

by:
footech earned 500 total points
Comment Utility
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
Comment Utility
Perfect, footech. Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

728 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

12 Experts available now in Live!

Get 1:1 Help Now