Skip to content

Instantly share code, notes, and snippets.

@kbhunut
Created April 5, 2020 16:16
Show Gist options
  • Save kbhunut/3cc9844816e7af41fccae4c77769062a to your computer and use it in GitHub Desktop.
Save kbhunut/3cc9844816e7af41fccae4c77769062a to your computer and use it in GitHub Desktop.
New Exchange Users Onboarding
# Create Mailbox via Powershell
# https://docs.microsoft.com/en-us/exchange/recipients/create-user-mailboxes?view=exchserver-2019
# https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/new-mailbox?view=exchange-ps
$defaultPassword = ConvertTo-SecureString -String 'Pa$$word1' -AsPlainText -Force
New-Mailbox -Name "Pilar Pinilla" -UserPrincipalName [email protected] -Password -FirstName 'Pilar' -LastName 'Pinilla' -ResetPasswordOnNextLogon $true -OrganizationalUnit "OU=NYC,DC=Contoso,DC=Com"
# How to do in Bulk Create via CSV
# CSV Header - Name,FirstName,LastName,UserPrincipalName,OU
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-7
Import-CSV ./bulk_creation.csv | Foreach {
$defaultPassword = ConvertTo-SecureString -String 'Pa$$word1' -AsPlainText -Force
# Splatter to make it more readable
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7
$arguments = @{
Name = $_.Name
FirstName = $_.FirstName
LastName = $_.LastName
UserPrincipalName = $_.UserPrincipalName
Password = $defaultPassword
ResetPasswordOnNextLogon = $true
OrganizationalUnit = $_.OU
}
New-Mailbox @arguments
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment