Last active
June 26, 2018 20:47
-
-
Save zackn9ne/bb5dcc6801e3e244ee3aa4db3e3ae1c5 to your computer and use it in GitHub Desktop.
powershell add user megascript
This file contains 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
#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