A)
Create user mailboxes in Exchange Online:
We have to use the Microsoft 365 admin center or Exchange
Online PowerShell to create an Exchange Online user mailbox. You can't
create new user mailboxes using the new Exchange admin center (EAC). However,
after Exchange Online mailboxes are created, you can manage them using the new
EAC.
Or you can assign M365 E3 license and related apps
Use the Microsoft 365 admin center to create a new
mailbox
We can use the Microsoft 365 admin center to create a new
user account. When you assign the user account a license for Exchange Online, a
mailbox is automatically created for the user.
To create a user mailbox using Microsoft Graph
PowerShell and assign an Exchange Online Plan 2 license, follow
these steps:
Prerequisites:
Install-Module Microsoft.Graph -Scope CurrentUser
Create the User:
Get Available SKUs:
Get-MgSubscribedSku | Select SkuPartNumber, SkuId
After user account is provisioned, assign a license:
Get Available SKUs:
Get-MgSubscribedSku | Select SkuPartNumber, SkuId
Assign the License:
# Replace this with the actual value from step 2
$skuId = "your-sku-id-here"
# Build the license object
$License = New-Object -TypeName
Microsoft.Graph.PowerShell.Models.MicrosoftGraphAssignedLicense
$License.SkuId = $skuId
# Add license to the user
Set-MgUserLicense -UserId
"Krish@imech544.onmicrosoft.com" -AddLicenses @($License)
-RemoveLicenses @()
Managing User Mailboxes in Exchange Online
1. Using Microsoft 365 Admin Center
Steps to manage mailboxes:
1. Visit https://admin.microsoft.com
2. Navigate to Users → Active users
3. Select a user and choose 'Mail' settings
Common Actions:
- Set mailbox aliases
- Manage email forwarding
- Add mailbox permissions (Send As, Send on Behalf, Full Access)
- Convert user mailbox to shared
- Create mailbox rules
Mailbox Storage:
- Check mailbox quota under 'Mailbox usage'
- Modify storage limits via assigned license (EOP2 = 100 GB)
2. Using Microsoft Graph PowerShell
Connect to Microsoft Graph:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.Read.All",
"User.ReadWrite.All", "Directory.ReadWrite.All",
"MailboxSettings.Read", "MailboxSettings.ReadWrite"
Examples:
# View mailbox settings
Get-MgUserMailboxSetting -UserId "user@domain.com"
# Disable automatic replies
Update-MgUserMailboxSetting -UserId "user@domain.com" -BodyParameter
@{
AutomaticRepliesSetting = @{
Status = "disabled"
}
}
3. Using Exchange Online PowerShell
Use for advanced mailbox tasks.
Install and connect:
Install-Module ExchangeOnlineManagement
Connect-ExchangeOnline
Examples:
# View mailbox
Get-EXOMailbox -Identity "user@domain.com"
# Convert to shared mailbox
Set-Mailbox -Identity "user@domain.com" -Type Shared
# Assign Full Access permissions
Add-MailboxPermission -Identity "user@domain.com" -User
"admin@domain.com" -AccessRights FullAccess -InheritanceType All
b) Delete or restore user mailboxes in Exchange Online
There are several things you should consider before you
decide to delete a user mailbox. There are different kinds of deletions that
you can do on a user mailbox and some of them won't allow you to restore or
recover the mailbox. This article walks you through the deleted mailbox
scenarios, and how to delete, recover or permanently remove a mailbox from
Exchange Online.
In Microsoft 365 and Exchange Online, the distinction
between a soft-deleted and a hard-deleted user mailbox is critical for data
recovery and administration. The primary difference lies in whether the mailbox
and its data are still recoverable.
Soft-Deleted User Mailboxes
A soft-deleted mailbox is in a transitional state and is
fully recoverable. This state is typically a safety net for accidental
deletions.
Key Characteristics:
- Deletion
Method: The user account associated with the mailbox is deleted from
the Microsoft 365 admin center or with PowerShell. The mailbox itself is
disconnected from the user but is not immediately purged.
- Retention
Period: The mailbox is retained in a soft-deleted state for 30 days
by default. During this time, the mailbox data remains intact on the
Exchange Online servers.
- Recoverability:
A soft-deleted mailbox can be restored easily. The most common method is
to restore the corresponding user account from the Microsoft Entra ID
(formerly Azure AD) recycle bin. When the user account is restored, the
mailbox automatically reconnects and becomes active again, along with all
its content.
- Visibility:
In the Exchange admin center, the mailbox will not be visible in the list
of active mailboxes. You can view it using PowerShell commands
specifically for soft-deleted mailboxes.
Hard-Deleted User Mailboxes
A hard-deleted mailbox is permanently removed from the
system. This state is irreversible and signifies that the mailbox data is gone
for good.
Key Characteristics:
- Deletion
Method: A mailbox becomes hard-deleted in one of a few ways:
- The
30-day soft-deletion retention period expires without the user being
restored.
- An
administrator explicitly and permanently deletes the mailbox using
PowerShell with the -PermanentlyDelete parameter.
- The
associated user account is hard-deleted from Microsoft Entra ID, and the
mailbox is not under any hold.
- Retention
Period: There is no retention period. Once hard-deleted, the mailbox
is purged from the Exchange Online database.
- Recoverability:
A hard-deleted mailbox is unrecoverable. Its contents, including
emails, contacts, and calendar items, are permanently gone. Recovery is
not possible through native Microsoft 365 tools, but may be possible if
you have a third-party backup solution.
- Visibility:
A hard-deleted mailbox is completely invisible in both the admin center
and through standard PowerShell commands.
Comparison Table
Feature |
Soft-Deleted Mailbox |
Hard-Deleted Mailbox |
State |
Disconnected and recoverable |
Permanently purged |
Retention Period |
30 days (default) |
None |
Contents |
Data is intact and preserved |
Data is permanently erased |
Recovery |
Easy to recover by restoring the user account |
Not recoverable through native tools |
Visibility |
Not visible in active mailboxes, but discoverable via
PowerShell |
Completely invisible and undiscoverable |
Administrator Action |
Occurs automatically upon user deletion or can be
initiated |
Occurs after retention period, or by forced deletion with
PowerShell |
Important Exception: Holds
The behavior of mailbox deletion changes significantly if
the mailbox is under a Litigation Hold or eDiscovery Hold. In
this scenario, even if the user account is hard-deleted, the mailbox is
retained as an inactive mailbox indefinitely. This ensures that the data
is preserved for compliance and legal purposes, even though the user can no
longer access it. Inactive mailboxes are a special form of soft-deleted mailbox
that bypasses the 30-day retention limit.
Lab Practice:
Deleting a user mailbox in Microsoft 365 can be accomplished
using the Microsoft 365 admin center or by using PowerShell. The method you
choose determines how the mailbox is handled—whether it's soft-deleted
(recoverable) or hard-deleted (permanently purged).
Here are the step-by-step instructions for both methods.
1. Using the Microsoft 365 Admin Center (Soft Delete)
This is the standard and safest method for deleting a
mailbox, as it puts the mailbox into a soft-deleted state, allowing for
recovery within 30 days.
- Sign
in to the Admin Center: Go to the Microsoft 365 admin center and sign
in with an account that has a Global Administrator or User Administrator
role.
- Navigate
to Active Users: In the navigation menu on the left, expand Users,
then click on Active users.
- Select
the User: Find and select the user whose mailbox you want to delete.
- Delete
the User: On the user's profile card, click the Delete user
button (or the trash can icon).
- Review
Deletion Options: A wizard will appear, asking what you want to do
with the user's data and license.
- Licenses:
You can choose to remove the license from the user and either keep it for
another user or remove it from your subscription.
- Mailbox
Data: You have the option to grant another user access to the deleted
user's mailbox data (if you want to migrate it or put it on hold).
- OneDrive:
You can also choose to give another user access to the OneDrive files.
- Confirm
Deletion: Follow the on-screen prompts and click Delete user to
finalize the process.
What Happens Next?
- The
user account is moved to the Deleted users list in Microsoft Entra
ID (formerly Azure AD).
- The
user's mailbox is disconnected from the account and becomes a soft-deleted
mailbox.
- The
mailbox and its contents are retained for 30 days. During this
period, you can restore the user, which automatically reconnects their
mailbox and all its data.
- After
30 days, the user account and the mailbox are permanently deleted from the
system and are unrecoverable.
2. Using PowerShell (Soft and Hard Delete)
Using PowerShell offers more granular control, including the
ability to permanently delete a mailbox immediately.
Step 1: Connect to Exchange Online PowerShell
Before you can run any commands, you must connect to
Exchange Online.
PowerShell
# Install the Exchange Online Management module if you
haven't already
Install-Module -Name ExchangeOnlineManagement
# Connect to Exchange Online
Connect-ExchangeOnline
Enter your administrator credentials when prompted.
Step 2: Soft Delete a Mailbox
This command is the PowerShell equivalent of deleting a user
in the admin center. It deletes the user account and soft-deletes the mailbox.
PowerShell
Remove-Mailbox -Identity "<UserPrincipalName>"
- Replace
<UserPrincipalName> with the user's email address or UPN (e.g., jane.doe@contoso.com).
- This
command will prompt for confirmation. If you want to skip the confirmation
prompt, you can add -Confirm:$false to the end of the command.
What Happens Next? Just like with the admin center
method, the mailbox enters a soft-deleted state for 30 days.
Step 3: Hard Delete a Soft-Deleted Mailbox (Permanent
Deletion)
This is a two-step process that permanently removes a
mailbox before the 30-day retention period is over. This is
irreversible.
- Get
the soft-deleted mailbox: You first need to find the mailbox, as it's
no longer considered an active mailbox.
PowerShell
Get-Mailbox -Identity "<UserPrincipalName>" -SoftDeletedMailbox
- This
command will display information about the soft-deleted mailbox.
- Permanently
delete the mailbox: Pipe the output of the previous command to the Remove-Mailbox
command with the -PermanentlyDelete parameter.
PowerShell
Get-Mailbox -Identity "<UserPrincipalName>" -SoftDeletedMailbox
| Remove-Mailbox -PermanentlyDelete
- You
will be asked for confirmation before the mailbox is permanently purged.
Important Considerations:
- Permissions:
You need the appropriate administrator roles (e.g., Exchange Administrator
or Global Administrator) to perform these actions.
- Holds:
If a mailbox is under a Litigation Hold or eDiscovery Hold,
it will not be permanently deleted. Instead, it will be converted into an inactive
mailbox, and the data will be preserved for compliance purposes until
the hold is removed.
- Irreversibility:
Be extremely careful when using the -PermanentlyDelete parameter. There is
no way to recover the data once this action is completed.