User Account Creation Script

1. Create Account in AD
a. Select the correct container
b. copy memberships of another user
c. add “proxyAddresses”
 
smtp:$username@kimconnect.com
smtp:$username@kimconnect.onmicrosoft.com
 
2. Run this script to sync with Office 365
————-
$serverName = EXCHANGE01
Invoke-Command -computername $serverName -scriptblock { Start-ADSyncSyncCycle -PolicyType Delta } -credential kimconnect-admin

Set-MsolUserPrincipalName -UserPrincipalName USERNAME@kimconnect.com -NewUserPrincipalName NEWUSERNAME@kimconnect.com
 
# Script to set primary SMTP for all AD users
Import-Module ActiveDirectory
$users = Get-ADUser -Filter *
foreach ($user in $users)
{
$email = $user.samaccountname + ‘@kimconnect.com’
$newemail = “SMTP:”+$email
Set-ADUser -Identity $user.SamAccountName -EmailAddress $email
Set-ADUser $user -Add @{proxyAddresses = ($newemail)}
}
 
# Script to add new user
New-ADUser -SamAccountName Firstname.Lastname -Name “Firstname Lastname” -GivenName Firstname -Surname Lastname -EmailAddress “Firstname.Lastname@kimconnect.com” -PasswordNeverExpires $true -AccountPassword (ConvertTo-SecureString -AsPlainText “PASSWORD” -Force) -PassThru | Enable-ADAccount

Leave a Reply

Your email address will not be published. Required fields are marked *