PEO Posted June 12, 2012 Report Posted June 12, 2012 Im have a stupid day so please help me out and then point and laugh My powershell script below running from my work station logged on as admin and get the follwing error import-module ac* $CSV = Import-CSV "C:\bg12.csv" $csv | foreach-object {New-ADUser -SamAccountName $_.UserName -UserPrincipalName $_.UserName -Name ($_.Surname + ", " + $_.Forename) -DisplayName ($_.Surname + ", " + $_.Forename) -Surname $_.Surname -GivenName $_.ForeName -Path "ou=12 Users,ou=students,dc=schoolname,dc=campus,dc=council" -AccountPassword (ConvertTo-SecureString -AsPlainText $_.Password -Force) -Enabled $true } $CSV | foreach-object {Set-ADUser -identity $_.samaccountname -replace @{mail=$_.email}} stupid error New-ADUser : Directory object not found At line:1 char:34 + $csv | foreach-object {New-ADUser <<<< -SamAccountName $_.UserName -UserPrincipalName $_.UserName -Name ($_.Su + ", " + $_.Forename) -DisplayName ($_.Surname + ", " + $_.Forename) -Surname $_.Surname -GivenName $_.ForeName - ou=12 users,ou=students,dc=schoolname,dc=campus,dc=council" -AccountPassword (ConvertTo-SecureString -AsPlainT .Password -Force) -Enabled $true } + CategoryInfo : ObjectNotFound: (CN=KIRK \, BRIA...pus,dc=stockton:String) [New-ADUser], ADIdentity undException + FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.NewADUser
PiqueABoo Posted June 12, 2012 Report Posted June 12, 2012 I don't have my Stuff[tm] to quickly reference, but offhand if the LDAP path is correct (Path) then it's could well be the Name it doesn't like. One of those properties, probably Name, gets used for the AD user object CN and there's a comma in it which might lead to some code failing to make sense of an object path like: CN=Bloggs,Fred,OU=12 Users,OU=Students,DC=.... 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now