More and more companies are moving to the cloud. Subscribing cloud services means less hardware maintenance, more comfort, and an “always-on” feeling. As an administrator, you have to get familiar with the administration of cloud services, especially with the basics like creating user accounts and user mailboxes. In this article I will carry out adding user accounts along with adding user mailboxes with Powershell.
Connect to Microsoft 365
Our starting point is to establish a connection to the Microsoft 365 | Exchange Online portal. In order to do that we need two commands. I’ll do anything with PowerShell 7. Feel free to use Windows PowerShell 5.1.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential (Get-Credential) -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
Finally, check your connection by running Microsoft 365 commands like Get-Mailbox.
Get-Mailbox
Adding new email-enabled Users
When a mailbox is created, a new user is also created at the same time. So, this is a one-stop shop.
The following example creates a user account and mailbox for the user Tom Huber. Tom must change the password at next logon.
New-Mailbox -Alias tomh -Name tomh -FirstName Tom -LastName Huber -DisplayName "Tom Huber" -MicrosoftOnlineServicesID tom.huber@sid-500.at -Password (ConvertTo-SecureString -String 'Pa$$w0rd' -AsPlainText -Force) -ResetPasswordOnNextLogon $true
To check if this has worked, run
Get-Mailbox Tomh | Format-Table -AutoSize
You can also take a look at your Office 365 portal.
The user must still be assigned a license. Assigning a license is out of scope of this blog post, but it’s worth to mention that you can do it right here.
See also
As mentioned before, you need to enter two commands to connect to the Office 365 portal. For your convenienve, I’ve created a Powershell function that connects you with a single command. For more, see Office 365 Exchange Online PowerShell: Quick connect with Connect-ExchangeOnline
Categories: Microsoft 365, PowerShell
world-class
LikeLike
this didnt work for me.
parameter cannot be found that matches parameter name ‘MicrosoftOnlineServicesID’.
+ CategoryInfo : InvalidArgument: (:) [New-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,New-Mailbox
+ PSComputerName : ppgimsexmgt01.parentpay.local
can anyone help?
LikeLike
local area network
LikeLike