Office 365 is a powerful enterprise platform that offers a wide range of business applications to help teams collaborate and organize daily tasks efficiently. Within this cloud ecosystem, PowerShell acts like a super-helper, simplifying technical tasks for administrators.
This video is designed for beginners, showing how to connect to PowerShell and access organizational user mailboxes without any hassle.
Open PowerShell as Administrator > Install the Exchange Online PowerShell Module.
** Install-Module -Name ExchangeOnlineManagement
This will install the ExchangeOnlineManagement module, which is used for managing Exchange Online. Now, Import the Module after installation:
** Import-Module ExchangeOnlineManagement
This ensures the module is loaded into your session. Once the module is installed and imported, you can connect to your Office 365 environment. Run the connection command:
** Connect-ExchangeOnline
Now, enter your credentials when prompted. You'll need to enter your admin username and password. Once connected, you can verify the session by running:
** Get-EXOMailbox
This will list mailboxes in your Exchange Online organization, confirming a successful connection.
Fetch user data > Run this command
** Get-Mailbox -ResultSize Unlimited
By default, PowerShell limits the results to 1,000 mailboxes. Adding -ResultSize Unlimited ensures you get a complete list, regardless of how many mailboxes exist in your organization.
"When you run Get-Mailbox -ResultSize Unlimited, you'll get a list with several columns, including:
Name: The mailbox name, which could be a user or a shared mailbox.
Alias: This is the part before the @ in the email address, like username.
Database: Shows where the mailbox is stored.
ProhibitSendQuota: This is the storage limit for the mailbox.
ExternalDirectoryObjectId: A unique identifier for each mailbox.
Let's move on and access individual mailboxes.
To get details for a specific mailbox, use the Get-Mailbox cmdlet with either the Name or Alias. Here's an example:
To get the details for the user with the alias abhishek, run:
** Get-Mailbox -Identity "abhishek"
Or if you want the mailbox for admin, run:
** Get-Mailbox -Identity "admin"
This will show detailed information about that specific mailbox."
"If you just want to see a list of mailboxes with their names and aliases, you can use this command:
** Get-Mailbox -ResultSize Unlimited | Select-Object Name, Alias
Once you've identified a mailbox, you might want to view its statistics, like size or last login time. To do that, run:
** Get-MailboxStatistics -Identity "abhishek"
If you want to check who has permissions on a mailbox, you can use the Get-MailboxPermission cmdlet. For example:
** Get-MailboxPermission -Identity "abhishek"
This will show all the users who have permissions on that mailbox."
Lastly, if you need to filter mailboxes based on certain criteria, like mailboxes starting with the alias shared, you can do this:
Get-Mailbox -ResultSize Unlimited | Where-Object { $_.Alias -like "shared*" }
This command will list all mailboxes with aliases that start with shared.
0 Comments