Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

New-ADUser Error

$
0
0

We have a script that runs twice every hour to create/update user accounts.  Until yesterday at 3:00 PM everything has been running fine.  I am now receiving the following error.  

I am sorta lost here.

 I am receiving the error on the New-ADuser file.

The error is:

New-ADUser : The server is unwilling to process the request
At C:\Accounts\Scriptorium\SFCC-Account-Provisioning-V2d1.ps1:157 char:2
+     New-ADUser -Name $User.sAMAccountName -AccountPassword $SecurePassword -Path $S ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=000076097,OU...C=SFCCMO,DC=EDU:String) [New-ADUser], ADException
    + FullyQualifiedErrorId : The server is unwilling to process the request,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Here is the function

Function CreateStudentUser {
 # We can sett all of the attributes we want to use with the New-ADUser
 # command, but we need to build a hash table to use with the
 # -OtherAttributes switch.
 $StudentAttributes=BuildUserTable $NewStudentAttributesArray
 # $StudentAttributes[0].Add('homeDirectory', $stushare + $User.sAMAccountName) # Students do not get H: drives.
 $StudentAttributes[0].Add('userPrincipalName', $UPN)
 $StudentAttributes[0].Add('pwdLastSet',0)
 # $StudentAttributes[0].Add('homeDrive', $homeDrive) # Students do not get H: drives.
 # John Tran, added for Office365
 $StudentAttributes[0].Add('targetAddress', $User.mail)
 $StudentAttributes[0].Add('proxyAddresses', "SMTP:" + $User.mail)
 
 $SecurePassword = ConvertTo-SecureString $User.info -AsPlainText -Force
 New-ADUser -Name $User.sAMAccountName -AccountPassword $SecurePassword -Path $StuOU -Enabled $true -OtherAttributes $StudentAttributes[0]
 
 # The New-ADUser command does not allow setting the Name (LDAP CN)
 # to a value different from the sAMAccountName, so we rename it after it
 # is created.
 $originalDN="CN=" + $User.sAMAccountName + "," + $StuOU
 Rename-ADObject $originalDN $User.displayName
 # CreateHomeFolder $StudentAttributes[0].homeDirectory # Students do not get H: drives.
 AddToGroups
}


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images