?
Solved

Active Directory PS script to modify attributes from CSV file

Posted on 2013-12-17
4
Medium Priority
?
3,422 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 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 2000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

800 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