Location: List Archives

List Archives

This forum is an archive of all posts to our mailing list over the past few years.  The forum is set read only therefore to contribute you will need to join our list community.  See more info about this here.

List Archives

Subject: FW: [ActiveDir] Verify Script
Prev Next
You are not authorized to post a reply.

AuthorMessages
KenBrownUser is Offline

Posts:0

07/28/2008 6:25 PM  
Please remove me from this list also.



From: ActiveDir-owner@mail.activedir.org [mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Salandra, Justin
Sent: Monday, July 28, 2008 4:01 PM
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] Verify Script

Yes

Justin A. Salandra
Network Engineer
Transatlantic Reinsurance Co.
80 Pine Street
7th Floor
New York, NY 10005
P: 212.770.2157
C: 917.455.0110
jsalandra@transre.com<mailto:jsalandra@transre.com>

From: ActiveDir-owner@mail.activedir.org [mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Brandon Shell
Sent: Monday, July 28, 2008 3:53 PM
To: ActiveDir@mail.activedir.org
Subject: Re: [ActiveDir] Verify Script

is it standard 1 initial lastname?
On Mon, Jul 28, 2008 at 3:41 PM, Salandra, Justin <jsalandra@transre.com<mailto:jsalandra@transre.com>> wrote:

I want this line of code to put in these results



jsalandra@domain.com<mailto:jsalandra@domain.com>



$objUser.Put("userPrincipalName",("{0}@domain.com<mailto:%7b0%7d@domain.com>" -f $dataRecords.FirstName,$dataRecord.LastName))



How do I achieve this?



Justin A. Salandra

Network Engineer



From: ActiveDir-owner@mail.activedir.org<mailto:ActiveDir-owner@mail.activedir.org> [mailto:ActiveDir-owner@mail.activedir.org<mailto:ActiveDir-owner@mail.activedir.org>] On Behalf Of Brandon Shell

Sent: Monday, July 28, 2008 3:21 PM
To: ActiveDir@mail.activedir.org<mailto:ActiveDir@mail.activedir.org>
Subject: Re: [ActiveDir] Verify Script



It looks like it will work fine, although I am a little unsure why you felt to the need to reference the properties twice.



Something like this Ώ]

foreach($dataRecord in (import-csv "NewUsers.csv")) {
#create the user account
$objOU = [ADSI]"LDAP://$($dataRecord.ou)"
$objUser = $objOU.Create("user","CN=$($dataRecord.cn)")
$objUser.Put("sAMAccountName",$dataRecord.sAMAccountName)
$objUser.Put("userPrincipalName",("{0}@domamin.com<mailto:%7B0%7D@domamin.com>" -f $dataRecords.FirstName,$dataRecord.LastName))
$objUser.Put("displayName",("{1},{0}" -f $dataRecords.FirstName,$dataRecord.LastName))
$objUser.Put("givenName",$dataRecords.FirstName)
$objUser.Put("sn",$dataRecord.LastName)
$objUser.Put("company",$dataRecord.company)
$objUser.Put("department",$dataRecord.department)
$objUser.Put("title",$dataRecord.title)
$objUser.Put("telephoneNumber",$telephoneNumber)
$objUser.Put("l",$dataRecord.City)
$objUser.Put("st",$dataRecord.State)
$objUser.Put("streetAddress",$dataRecord.Address)
$objUser.SetInfo()

#Set Password
$objUser.SetPassword($password)
$objUser.psbase.InvokeSet("AccountDisabled",$false)
$objUser.SetInfo()
}



Ώ] stardard joe disclaimer of not tested.


On Mon, Jul 28, 2008 at 3:08 PM, Salandra, Justin <jsalandra@transre.com<mailto:jsalandra@transre.com>> wrote:

Can some one give at this script and let me know if it would work? I want get the OU from the CSV file as different users are created in different locations. I have a CSV file associated with script with all the proper headings.



When we do get Exchange 2007 I can update this script to also create a New-Mailbox and pull in the all the additional info needed for that command from the CSV file.



Thanks



$dataSource=import-csv "NewUsers.csv"

foreach($dataRecord in $datasource) {

#map varibles to data source

$ou=$dataRecord.ou

$objOU=[ADSI]+"$ou"

$cn=$dataRecord.cn

$sAMAccountName=$dataRecord.sAMAccountName

$givenName=$dataRecords.FirstName

$sn=$dataRecord.LastName

$displayName=$sn + ", " + $givenName

$userPrincipalName=$givenName1 + $sn + "@domain.com<http://domain.com/>"

$company=$dataRecord.company

$department=$dataRecord.department

$title=$dataRecord.title

$telephoneNumber=$dataRecord.telephoneNumber

$streetAddress=$dataRecord.Address

$l=$dataRecord.City

$st=$dataRecord.State





#create the user account

$objUser=$objOU.Create("user","CN="+$cn)

$objUser.Put("sAMAccountName",$sAMAccountName)

$objUser.Put("userPrincipalName",$userPrincipalName)

$objUser.Put("displayName",$displayName)

$objUser.Put("givenName",$givenName)

$objUser.Put("sn",$sn)

$objUser.Put("company",$company)

$objUser.Put("department"$department)

$objUser.Put("title",$title)

$objUser.Put("telephoneNumber",$telephoneNumber)

$objUser.Put("l",$l)

$objUser.Put("st",$st)

$objUser.Put("streetAddress",$streetAddress)

$objUser.SetInfo()



#Set Password

$objUser.SetPassword(password)

$objUser.psbase.InvokeSet("AccountDisabled",$false)

$objUser.SetInfo()

}



Justin A. Salandra

Network Engineer

"IMPORTANT NOTICE: The information in this email

(and any attachments hereto) is confidential and may be

protected by legal privileges and work product immunities.

If you are not the intended recipient, you must not use or

disseminate the information. Receipt by anyone other than the

intended recipient is not a waiver of any attorney-client or work



product privilege. If you have received this email in error, please

immediately notify me by "Reply" command and permanently

delete the original and any copies or printouts thereof. Although

this email and any attachments are believed to be free of any virus

or other defect that might affect any computer system into which it

is received and opened, it is the responsibility of the recipient to

insure that it is virus free and no responsibility is accepted by

Transatlantic Reinsurance Company or its subsidiaries or affiliates

either jointly or severally, for any loss or damage arising in any way

from its use."









"IMPORTANT NOTICE: The information in this email

(and any attachments hereto) is confidential and may be

protected by legal privileges and work product immunities.

If you are not the intended recipient, you must not use or

disseminate the information. Receipt by anyone other than the

intended recipient is not a waiver of any attorney-client or work

product privilege. If you have received this email in error, please

immediately notify me by "Reply" command and permanently

delete the original and any copies or printouts thereof. Although

this email and any attachments are believed to be free of any virus

or other defect that might affect any computer system into which it

is received and opened, it is the responsibility of the recipient to

insure that it is virus free and no responsibility is accepted by

Transatlantic Reinsurance Company or its subsidiaries or affiliates

either jointly or severally, for any loss or damage arising in any way

from its use."








"IMPORTANT NOTICE: The information in this email

(and any attachments hereto) is confidential and may be

protected by legal privileges and work product immunities.

If you are not the intended recipient, you must not use or

disseminate the information. Receipt by anyone other than the

intended recipient is not a waiver of any attorney-client or work

product privilege. If you have received this email in error, please

immediately notify me by "Reply" command and permanently

delete the original and any copies or printouts thereof. Although

this email and any attachments are believed to be free of any virus

or other defect that might affect any computer system into which it

is received and opened, it is the responsibility of the recipient to

insure that it is virus free and no responsibility is accepted by

Transatlantic Reinsurance Company or its subsidiaries or affiliates

either jointly or severally, for any loss or damage arising in any way

from its use."







You are not authorized to post a reply.
Forums >ActiveDir Mail List Archive >List Archives > FW: [ActiveDir] Verify Script



ActiveForums 3.7
AdventNet Banner
Friends

Friends

Namescape
Members

Members

MembershipMembership:
Latest New UserLatest:cthart
New TodayNew Today:1
New YesterdayNew Yesterday:5
User CountOverall:4285

People OnlinePeople Online:
VisitorsVisitors:75
MembersMembers:0
TotalTotal:75

Online NowOnline Now:

Ads

Copyright 2008 ActiveDir.org
Terms Of Use