Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Issue with importing users to AD

$
0
0

Having trouble importing users to AD from a csv. The csv contains: firstname, lastname, password, ou

We will say the record is: test, user1, password, All Users

Here's the script (redacted/changed/ya know):

Powershell
Import-ModuleActiveDirectory$Users=Import-Csv-Delimiter","-Path"filepath.csv"foreach($Userin$Users){$OU=$User.OU+",DC=domain,DC=com"$Password=$User.password$Detailedname=$User.firstname+" "+$User.lastname$UserFirstname=$User.Firstname$FirstLetterFirstname=$UserFirstname.substring(0,1)$SAM=$FirstLetterFirstname+$User.lastnameNew-ADUser-DisplayName$Detailedname-SamAccountName$SAM-UserPrincipalName$SAM-GivenName$user.firstname-Surname$user.lastname-AccountPassword(ConvertTo-SecureString$Password-AsPlainText-Force)-Enabled$true-Path$OU}

Remote pssession. Script starts to...


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

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