Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Active Directory Import users from csv through powershell

$
0
0

Hi,

I have tried several scripts to import users into AD via CSV. I'd like to simplify the import if I can. Here's what I'd like to use:

Import-Csv "c:\temp\Users.csv" | foreach-object {$userprinicpalname = $_.AccountName + "@company.com"
New-ADUser -SamAccountName $_.AccountName -UserPrincipalName $userprinicpalname -Name $_.name -DisplayName $_.name -Title $_.Title -Department $_.Department -Company $_.Company -Manager $_.Manager -Description $_.Description -Path "CN=employees,DC=company,DC=com" -AccountPassword (ConvertTo-SecureString "password" -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru }

When I run this script I get an error on "New-ADUser : Directory object not found". I also have my CSV formatted with the headers mentioned in the script setup in the order the script calls them.

Any assistance would be greatly appreciated. Thanks.


Georgi


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>