Created
March 6, 2018 16:58
-
-
Save primetoxinz/002707c90eba27243c8f03d16ccf979d to your computer and use it in GitHub Desktop.
Create User for AD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$path, | |
[string]$first_name, | |
[string]$last_name, | |
[string]$user_name, | |
[string]$password | |
) | |
function CreateUser { | |
param ( | |
[string]$path, | |
[string]$first_name, | |
[string]$last_name, | |
[string]$user_name, | |
[string]$password | |
) | |
echo "Creating: $first_name $last_name - $user_name | |
$securepassword = ConvertTo-SecureString $password -AsPlainText -Force | |
New-AdUser -Name $user_name -GivenName $first_name -Surname $last_name -AccountPassword $securepassword | |
} | |
If($path) { | |
$file = Get-Content $path { | |
foreach($line in $file) { | |
$user = $line.Split(","); | |
createUser @user | |
} | |
} else { | |
createUser($first_name, $last_name, $user_name, $password) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment