Skip to content

Instantly share code, notes, and snippets.

@terrytrent
Created April 29, 2016 14:43
Show Gist options
  • Save terrytrent/a675f1cc7d6fbad28ae23e6e1ef6d05d to your computer and use it in GitHub Desktop.
Save terrytrent/a675f1cc7d6fbad28ae23e6e1ef6d05d to your computer and use it in GitHub Desktop.
[Reflection.Assembly]::LoadWithPartialName("System.Web")
$Credentials=$(get-credentials)
$RandomPassword=[System.Web.Security.Membership]::GeneratePassword(10,0)
$domainLocal='ad.fattswindstormelec.com'
$domainPublic='fattswindstormelec.com'
$UserFirst='Poopy'
$UserLast='McButthole'
$Name="$UserFirst $UserLast"
$SamAccountName="$($UserFirst.substring(0,1))$($UserLast.substring(0,7))"
$UserPrincipalName="$SamAccountName@$domainLocal"
$Email="$UserFirst.$UserLast@$domainpublic"
$OrganizationalUnit='OU=Office, OU=fattswindstorm Electrical,DC=fattswindstormelec,DC=com'
New-ADUser -Name $Name -DisplayName $Name -EmailAddress $Email -Enabled $true -GivenName $UserFirst -Surname $UserLast -SamAccountName $SamAccountName -UserPrincipalName $UserPrincipalName -AccountPassword $($RandomPassword | ConvertTo-SecureString -Force -AsPlainText) -ChangePasswordAtLogon $true -Credential $Credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment