Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Adding Users with PowerShell script

$
0
0
Here is my code and for some reason it wont add it in. Seems to work but the users are not listed. Import-Csv .\users1.csv { foreach-object $userprinicpalname = $_.SamAccountName + "@XXXXXX" ; New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $_.userprinicpalname -Name $_.name -EmailAddress $_.E-Mail -DisplayName $_.Name -GivenName $_.FirstName -SurName $_.LastName -replace @{msnpallowdialin=$true} -Path $_.path; Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText $_.Password -Force) ; Enable-ADAccount -identity $_.SamAccountName; Set-ADUser -Identity $_.SamAccountName -ChangePasswordAtLogon $true }

Viewing all articles
Browse latest Browse all 21975

Trending Articles



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