Solved

Active Directory PS script to modify attributes from CSV file

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
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 setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

821 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