Forum Search:
Forum.Brain-Cluster.com: Brain Cluster Technical Forum
Ultimate forum for Technical Discussions

Home » Microsoft » Windows Server » Active Directory » Change user attribute through CSV file
Change user attribute through CSV file [message #159985] Fri, 14 August 2009 08:58 Go to next message
Luiz  is currently offline Luiz
Messages: 119
Registered: July 2009
Senior Member
Hi,

I need some help so If anyone can help me I appreciate:
- I need change email atribute of 300 users. I have a file(csv) of the
emails but I would like to know how can I change that attribute automatically.

Any tip?

Thanks.

Luiz
RE: Change user attribute through CSV file [message #159988 is a reply to message #159985] Fri, 14 August 2009 10:28 Go to previous messageGo to next message
TPGBrennan  is currently offline TPGBrennan
Messages: 10
Registered: August 2009
Junior Member
There are several ways to handle this: VBScript, PowerShell, or LDAP to
import the changes from your csv file. This powershell snippet should do the
trick; you will need the Quest ActiveRoles Management cmdlets in addition to
the standard Microsoft Powershell.

#To set attributes for a list of users from a csv file
Import-CSV -path c:\email.csv | ForEach {set-qaduser -id $_.user -email
$_.email}

the import csv is c:\email.csv with two columns, one labeled user with the
login id of the user, the second labeled email with the new email attribute
value.

"Luiz" wrote:

> Hi,
>
> I need some help so If anyone can help me I appreciate:
> - I need change email atribute of 300 users. I have a file(csv) of the
> emails but I would like to know how can I change that attribute automatically.
>
> Any tip?
>
> Thanks.
>
> Luiz
Re: Change user attribute through CSV file [message #159989 is a reply to message #159985] Fri, 14 August 2009 10:34 Go to previous messageGo to next message
Cary Shultz  is currently offline Cary Shultz  United States
Messages: 127
Registered: August 2009
Senior Member
Unless I am sadly mistaken, you can not make changes via csvde.

However, you can use a csv file - in conjunction with some other 'delivery
method' - to make changes...as already indicated.

HTH,

Cary

"Luiz" <Luiz@discussions.microsoft.com> wrote in message
news:06AAF788-2E0B-48DF-A349-3724CCA9C90B@microsoft.com...
> Hi,
>
> I need some help so If anyone can help me I appreciate:
> - I need change email atribute of 300 users. I have a file(csv) of the
> emails but I would like to know how can I change that attribute
> automatically.
>
> Any tip?
>
> Thanks.
>
> Luiz
Re: Change user attribute through CSV file [message #159992 is a reply to message #159985] Fri, 14 August 2009 10:54 Go to previous messageGo to next message
rlmueller-nospam  is currently offline rlmueller-nospam  United States
Messages: 292
Registered: July 2009
Senior Member
Luiz wrote:

>
> I need some help so If anyone can help me I appreciate:
> - I need change email atribute of 300 users. I have a file(csv) of the
> emails but I would like to know how can I change that attribute
> automatically.
>
> Any tip?
>

Another option is a VBScript program. However, VBScript programs can read
comma delimited files, but it is not easy. It's actually much easier to read
an Excel spreadsheet. You can easily convert your csv to an xls. I have an
example VBScript program that reads user Distinguished Name (DN) and profile
path from a spreadsheet and updates the profilePath attribute of the users
linked here:

http://www.rlmueller.net/UpdateUserProfile.htm

You can easily modify this to modify the mail attribute instead, by
replacing "profilePath" with "mail" throughout. There is also a link to a
VBScript program to create a spreadsheet with the DN's of all users, if that
helps.

If instead of user Distinguished Names, your text file identifies the users
by "pre-Windows 2000 logon name" (sometimes called UserID or UserName), more
work is required. I have an example for this as well linked here:

http://www.rlmueller.net/UpdateUserProfile2.htm

If you must read a csv file in VBScript, the best method is to use the Jet
OLEDB driver. For example (in brief):
============
Option Explicit

Dim adoConnection, adoRecordset
Dim strPathToTextFile
Dim strUserDN, strMail, objUser

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set adoConnection = CreateObject("ADODB.Connection")
Set adoRecordset = CreateObject("ADODB.Recordset")

' Specify path. The specific file is specified in
' the SQL query statement below.
strPathtoTextFile = "C:\Scripts\"

adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strPathtoTextFile & ";" _
& "Extended Properties=""text;HDR=YES;FMT=Delimited"""

adoRecordset.Open "SELECT * FROM Users.csv", _
adoConnection, adOpenStatic, adLockOptimistic, adCmdText

' Read the csv file.
Do Until adoRecordset.EOF
strUserDN = adoRecordset.Fields.Item("User")
strMail = adoRecordset.Fields.Item("Email")
' Bind to the user object.
Set objUser = GetObject("LDAP://" & strUserDN)
' Assign the mail attribute.
objUser.mail = strMail
' Save changes.
objUser.SetInfo
adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close
========
I've assumed a header line in the file specifying the fields "User" and
"Email", where the value in the "User" field is the Distinguished Name of
the user. I hope this helps. I did not use error trapping in this quick
example, so the script will halt if it encounters a bad DN.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
RE: Change user attribute through CSV file [message #159996 is a reply to message #159988] Fri, 14 August 2009 12:38 Go to previous messageGo to next message
Luiz  is currently offline Luiz
Messages: 119
Registered: July 2009
Senior Member
Hi TPGBrennan,

thank you for the help.


Best Regards.


Luiz



"TPGBrennan" wrote:

> There are several ways to handle this: VBScript, PowerShell, or LDAP to
> import the changes from your csv file. This powershell snippet should do the
> trick; you will need the Quest ActiveRoles Management cmdlets in addition to
> the standard Microsoft Powershell.
>
> #To set attributes for a list of users from a csv file
> Import-CSV -path c:\email.csv | ForEach {set-qaduser -id $_.user -email
> $_.email}
>
> the import csv is c:\email.csv with two columns, one labeled user with the
> login id of the user, the second labeled email with the new email attribute
> value.
>
> "Luiz" wrote:
>
> > Hi,
> >
> > I need some help so If anyone can help me I appreciate:
> > - I need change email atribute of 300 users. I have a file(csv) of the
> > emails but I would like to know how can I change that attribute automatically.
> >
> > Any tip?
> >
> > Thanks.
> >
> > Luiz
Re: Change user attribute through CSV file [message #159997 is a reply to message #159992] Fri, 14 August 2009 12:39 Go to previous message
Luiz  is currently offline Luiz
Messages: 119
Registered: July 2009
Senior Member
Hi Richard,

thank you for the help.

Best Regards.

Luiz

"Richard Mueller [MVP]" wrote:

> Luiz wrote:
>
> >
> > I need some help so If anyone can help me I appreciate:
> > - I need change email atribute of 300 users. I have a file(csv) of the
> > emails but I would like to know how can I change that attribute
> > automatically.
> >
> > Any tip?
> >
>
> Another option is a VBScript program. However, VBScript programs can read
> comma delimited files, but it is not easy. It's actually much easier to read
> an Excel spreadsheet. You can easily convert your csv to an xls. I have an
> example VBScript program that reads user Distinguished Name (DN) and profile
> path from a spreadsheet and updates the profilePath attribute of the users
> linked here:
>
> http://www.rlmueller.net/UpdateUserProfile.htm
>
> You can easily modify this to modify the mail attribute instead, by
> replacing "profilePath" with "mail" throughout. There is also a link to a
> VBScript program to create a spreadsheet with the DN's of all users, if that
> helps.
>
> If instead of user Distinguished Names, your text file identifies the users
> by "pre-Windows 2000 logon name" (sometimes called UserID or UserName), more
> work is required. I have an example for this as well linked here:
>
> http://www.rlmueller.net/UpdateUserProfile2.htm
>
> If you must read a csv file in VBScript, the best method is to use the Jet
> OLEDB driver. For example (in brief):
> ============
> Option Explicit
>
> Dim adoConnection, adoRecordset
> Dim strPathToTextFile
> Dim strUserDN, strMail, objUser
>
> Const adOpenStatic = 3
> Const adLockOptimistic = 3
> Const adCmdText = &H0001
>
> Set adoConnection = CreateObject("ADODB.Connection")
> Set adoRecordset = CreateObject("ADODB.Recordset")
>
> ' Specify path. The specific file is specified in
> ' the SQL query statement below.
> strPathtoTextFile = "C:\Scripts\"
>
> adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
> & "Data Source=" & strPathtoTextFile & ";" _
> & "Extended Properties=""text;HDR=YES;FMT=Delimited"""
>
> adoRecordset.Open "SELECT * FROM Users.csv", _
> adoConnection, adOpenStatic, adLockOptimistic, adCmdText
>
> ' Read the csv file.
> Do Until adoRecordset.EOF
> strUserDN = adoRecordset.Fields.Item("User")
> strMail = adoRecordset.Fields.Item("Email")
> ' Bind to the user object.
> Set objUser = GetObject("LDAP://" & strUserDN)
> ' Assign the mail attribute.
> objUser.mail = strMail
> ' Save changes.
> objUser.SetInfo
> adoRecordset.MoveNext
> Loop
>
> adoRecordset.Close
> adoConnection.Close
> ========
> I've assumed a header line in the file specifying the fields "User" and
> "Email", where the value in the "User" field is the Distinguished Name of
> the user. I hope this helps. I did not use error trapping in this quick
> example, so the script will halt if it encounters a bad DN.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
Re: Change user attribute through CSV file [message #159998 is a reply to message #159989] Fri, 14 August 2009 12:39 Go to previous message
Luiz  is currently offline Luiz
Messages: 119
Registered: July 2009
Senior Member
Thank you Cary.

Best REgards.

Luiz

"Cary Shultz" wrote:

> Unless I am sadly mistaken, you can not make changes via csvde.
>
> However, you can use a csv file - in conjunction with some other 'delivery
> method' - to make changes...as already indicated.
>
> HTH,
>
> Cary
>
> "Luiz" <Luiz@discussions.microsoft.com> wrote in message
> news:06AAF788-2E0B-48DF-A349-3724CCA9C90B@microsoft.com...
> > Hi,
> >
> > I need some help so If anyone can help me I appreciate:
> > - I need change email atribute of 300 users. I have a file(csv) of the
> > emails but I would like to know how can I change that attribute
> > automatically.
> >
> > Any tip?
> >
> > Thanks.
> >
> > Luiz
>
>
Previous Topic:SID History not working
Next Topic:USN Rollback
Goto Forum:
  


Current Time: Thu Jan 18 20:49:11 MST 2018

Total time taken to generate the page: 0.02380 seconds
.:: Contact :: Home ::Sitemap::.

Powered by: FUDforum 3.0.0RC2.
Copyright ©2001-2009 FUDforum Bulletin Board Software