I
I
ireapzz122020-01-09 17:49:52
PowerShell
ireapzz12, 2020-01-09 17:49:52

AD PowerShell error in code?

Please tell me who knows.
PiVQLL6l.png

Import-Csv "C:\users.csv" -Delimiter ";" | ForEach-Object {
$upn = $_.SamAccountName + “@nfbgu”
$uname = $_.LastName + " " + $_.FirstName
New-ADUser -Name $uname `
-DisplayName $uname `
-GivenName $_.FirstName `
-Surname $_.LastName `
-EmailAddress $_.EmailAddress`
-UserPrincipalName $upn `
-SamAccountName $_.samAccountName `
-Path $_.OU `
-AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -Enabled $true
}

3aII8j3i.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Choporov, 2020-01-09
@tolstyiii

So far, offhand - your OU is incorrectly specified.

E
Eugene, 2020-01-09
@BeatHazard

In the CSV file, you have an error in the OU field. The path to the OU is "OU=nfbgu,DC=nfbgu,D=local",
should be "OU=nfbgu,DC=nfbgu,DC=local"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question