Recent Blue Posts
Recent Forum Posts
Titan
Need help with powershell.
So I'm working on some powershell homework. my objective is to use an array to create two users in active directory in an OU. The information for these users is supposed to be in a txt file that I created. I can't get it to create the second user. Any help I can get would be greatly appreciated.
This is what I have:
$arytext = get-content -path "C:\Users\Administrator\Documents\labfinal-1.txt"
$strClass = "user"
$intUsers = 2
$strName = "cn=Jon Archer","cn=Picard"
$objADSI = [ADSI]"LDAP://ou=FinalExam,dc=jdcomp,dc=local"
for($i=1; $i -le $intUsers; $i++)
{
$objUser = $objADSI.create($strClass, $strName)
$objUser.setInfo()
$objUser.put("GivenName", $aryText[0])
$objuser.put("Initials", $aryText[1])
$objuser.put("SN", $aryText[2])
$objuser.put("DisplayName", $aryText[3])
$objuser.put("Description", $aryText[4])
$objuser.put("TelephoneNumber", $aryText[5])
$objuser.put("Mail", $aryText[6])
$objuser.put("streetAddress", $aryText[7])
$objuser.put("l", $aryText[8])
$objuser.put("st", $arytext[9])
$objUser.put("postalcode", $arytext[10])
$objUser.put("C", $arytext[11])
$objuser.put("co", $arytext[12])
$objuser.put("CountryCode", $arytext[13])
$objUser.setInfo()
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts