-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateADaccounts.ps1
28 lines (26 loc) · 1.11 KB
/
CreateADaccounts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<#
NAME: CreateADaccounts.ps1
AUTHOR: Andrew Lamarra
CREATED: 7/15/2015
COMMENTS: This script will add a bunch of accounts to AD from a CSV file.
#>
Import-Csv "C:\Users\Administrator\Desktop\Adding Users\final.csv" | `
ForEach-Object {
$UPN = $_."SAMAccountName" + '@' + (Get-ADDomain).DNSRoot
$path = "OU=" + $_."MemberOf" + "," + (Get-ADDomain).DistinguishedName
New-ADUser -Name $_."DisplayName" `
-DisplayName $_."DisplayName" `
-SamAccountName $_."SAMAccountName" `
-GivenName $_."GivenName" `
-Initials $_."Initials" `
-Surname $_."Surname" `
-Description $_."Description" `
-Company $_."Company" `
-Path $path `
-UserPrincipalName $UPN `
-AccountPassword (ConvertTo-SecureString "Bure@u123" -AsPlainText -Force) `
-ChangePasswordAtLogon $true `
-Enabled $true `
-OtherAttributes @{'TelephoneNumber'=$_."TelephoneNumber"}
# Add-ADGroupMember "Domain Admins" $_."samAccountName"
}