Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Last active June 26, 2018 20:47
Show Gist options
  • Save zackn9ne/bb5dcc6801e3e244ee3aa4db3e3ae1c5 to your computer and use it in GitHub Desktop.
Save zackn9ne/bb5dcc6801e3e244ee3aa4db3e3ae1c5 to your computer and use it in GitHub Desktop.
powershell add user megascript
#example vars
$acn = "sjobs"
$first = "Steve"
$last = "Jobs"
$pass= "secretwords"
$domain1 = "ca"
$domain2 = "apple"
$domain3 = "com"
$secretOU = "AppleComputers"
# smart vars
$fullname = $first + " " + $last
$domaincombined = $domain1 + "." + $domain2 + "." + $domain3
New-ADUser -Name $fullname -GivenName $first -Surname $last -Path "OU=Staff,OU=$secretOU,DC=$domain1,DC=$domain2,DC=$domain3" -sAMAccountName $acn -UserPrincipalName "$acn@$domaincombined" -Enabled $True -PasswordNeverExpires $true -CannotChangePassword $true -AccountPassword (ConvertTo-SecureString -AsPlainText -Force -String $pass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment