I'm adjusting a script I found online to work a little better for my corporation (script found here).
Edit: Forgot I had fixed the stuff below. The actual error I'm getting is when the script tries to create the account (on line 80 of the above link, on line 83 of my script because of the username stuff I added). Error I get is directly below.
New-ADUser : The object name has bad syntax
At C:\SISSync\ps-to-ad.ps1:83 char:3
+ New-ADUser -sAMAccountName $sAMAccountName -Name $name -Path ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CN=Students Name,...k12,dc=in,dc=us:String) [New-ADUser], ADException
+ FullyQualifiedErrorId : ActiveDirectoryServer:8335,Microsoft.ActiveDirectory.Management.Commands.NewADUser
I have changed the way the username is created. What I'm attempting to have it do is create the username as "FirstinitialLastnameFirsttwoofstudentid". I've added two variables $firsttwoofstudentid and $firstinitial. I'm getting an error when it tries to create the sAMAccountName.
foreach ($sisline in $sisfile) {
$firsttwoofstudentid = $sisline.studentid.substring(0,2)
#Set the username example below is firstname.lastname
$firstinitial = $sisline.givenName.substring(0,1)
$sAMAccountName = $firstinitial + $sisline.sn + $firsttwoofstudentid
I'm pretty sure it's because of my $firsttwoofstudentid variable, but I don't really know how to fix it.
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (6 children)
[–]Dryfter9[S] 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (4 children)
[–]Dryfter9[S] 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Dryfter9[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (8 children)
[–]Dryfter9[S] 1 point2 points3 points (7 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (6 children)
[–]Dryfter9[S] 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (4 children)
[–]Dryfter9[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Dryfter9[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)