Skip to content

Instantly share code, notes, and snippets.

@primetoxinz
Created March 6, 2018 16:58
Show Gist options
  • Save primetoxinz/002707c90eba27243c8f03d16ccf979d to your computer and use it in GitHub Desktop.
Save primetoxinz/002707c90eba27243c8f03d16ccf979d to your computer and use it in GitHub Desktop.
Create User for AD
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