Saturday, May 11, 2024
HomePowershelluse Get-Mailbox in PowerShell — LazyAdmin

use Get-Mailbox in PowerShell — LazyAdmin


Wish to export all mailboxes from Trade? Or have to search for the mailbox settings from a specific consumer? With the cmdlet Get-Mailbox in PowerShell, we will rapidly extract all data that we’d like from the Trade On-line server.

You’ll find just about all mailbox data within the Trade Admin middle, however as you may need seen, this isn’t at all times the quickest solution to search for data. Particularly while you wish to get or export mailbox data from a number of customers, then you will have to make use of PowerShell.

On this article, we’re going to try learn how to use the Get-Mailbox cmdlet in PowerShell. I’ll give some helpful examples relating to discovering and exporting mailbox data. And as a bonus, I’ve added a whole script to a very powerful data out of your mailboxes.

Set up the Trade On-line Module

Earlier than we will use the Get-Mailbox cmdlet in PowerShell you will have to put in the Trade On-line module. Just be sure you set up the most recent Trade On-line v3 Module, which you need to use on PowerShell 5 and seven.

Word

The Get-Mailbox cmdlet will also be used on an on-premise Trade Server model 2010 and better, however for the on-premise model you will have to make use of the Trade Administration Shell

On this article, I’ll concentrate on the Trade On-line server. Just be sure you are linked to Trade On-line:

Join-ExchangeOnline -UserPrincipalName [email protected]

Discovering Mailboxes with Get Mailbox in PowerShell

The Get Mailbox cmdlet permits us to search out mailboxes from the Trade On-line server and extract data from them. The benefit of the cmdlet is that we will use completely different choices to search out or filter the mailboxes.

We will use the next choices to search out mailboxes:

  • Anr – Discover a mailbox by a part of the identify (ambiguous identify decision)
  • Identification – Discover mailbox primarily based on the identify, consumer area identify, or e mail handle
  • Filter – Retrieve a number of mailboxes primarily based on a question
  • MailboxPlan – Get all mailboxes which can be assigned a particular mailbox plan
  • RecipientTypeDetails – Return solely the required mailbox kind

If you realize the e-mail handle or identify of the mailbox that you just want, then the identification parameter is the commonest solution to choose the mailbox:

# Discover the mailbox on identify or alias
Get-Mailbox -Identification adelev

# Utilizing the e-mail handle to search out the mailbox
Get-Mailbox -Identification [email protected]
get mailbox
Get Mailbox

A quicker possibility to search out the mailbox that you just want is to make use of the much less identified -anr parameter. This may do a ambiguous identify decision search with the required string and return all mailbox that matches. It searches on the next attributes:

  • CommonName
  • Displayname
  • First and final identify
  • Alias

Vital to notice is that you will want to enter not less than 3 characters of the mailbox identify. So if we wish to view the mailbox particulars from Adele Vance we will merely use the next command:

Get-Mailbox -anr ade

Utilizing the Filter possibility

The Get-Mailbox cmdlet incorporates loads of properties, and we will use most of them to filter the mailbox outcomes. So let’s check out a few generally used examples to search out the mailboxes:

To discover a mailbox on a part of the identify you might use the -anr parameter, as talked about earlier than. However we will additionally use the filter after all. The benefit of filter over anr is that you may filter all mailboxes that start or finish with the required string:

# Get all mailboxes that begin with 'di'
Get-Mailbox -Filter "Displayname -like 'di*'"

# Or get all mailboxes the place the identify ends with 'take a look at'
Get-Mailbox -Filter "Identify -like '*take a look at'"

Filter mailboxes on Quota’s

Once you wish to filter the mailboxes on one of many quotas (Archive, ProhibitSendQuota, IssueWarning, and so forth), then you will have seen that you just received’t be capable of filter on the quota dimension. For instance, this received’t work:

Get-Mailbox -Filter "IssueWarningQuota -lt '50GB'"

The issue is that you may solely use the filter together with the quota to verify if the property is about to limitless or not:

# Get all mailboxes had been the ProhibitSendReceiveQuota is about to limitless
Get-Mailbox -Filter "ProhibitSendReceiveQuota -eq 'Limitless'"

# Or not set to limitless
Get-Mailbox -Filter "ProhibitSendReceiveQuota -ne 'Limitless'"

To “filter” on the precise worth, we might want to get all mailboxes and use a the place filter:

# Get all mailboxes the place the problem warning quota is much less then 50GB
Get-Mailbox | the place {$_.IssueWarningQuota -lt '50GB'}

Get Mailboxes primarily based on the MailboxPlan

The -MailboxPlan parameter permits us to get all mailboxes which can be assigned a particular mailbox plan. Step one is to get all obtainable plans in your tenant:

Get-MailboxPlan | Choose DisplayName | ft

# Outcome
DisplayName
-----------
ExchangeOnline
ExchangeOnlineEnterprise
ExchangeOnlineEssentials
ExchangeOnlineDeskless

We will use the show names from the plans to filter the mailboxes:

# Get all of the mailboxes with the Trade ONline plan (more often than not shared or useful resource mailboxes)
Get-Mailbox -MailboxPlan ExchangeOnline

Filter on RecipientTypeDetails

In Trade, there are several types of mailboxes. In addition to the conventional usermailbox, we now have additionally the next sorts:

  • RoomMailbox
  • SharedMailbox
  • TeamMailbox
  • GroupMailbox
  • EquipmentMailbox

And these will not be even every type, however they’re the commonest ones. With the parameter RecipientTypeDetails, we will filter the outcomes primarily based on the mailbox kind. So if you wish to get all shared mailboxes, you may merely use the next cmdlet:

# Get all Shared mailboxes
Get-Mailbox -RecipientTypeDetails SharedMailbox

# Or all (assembly) room mailboxes
Get-Mailbox -RecipientTypeDetails RoomMailbox

Retrieve all Mailboxes

To easily retrieve all mailboxes we don’t should specify any filters. You solely have to set the ResultSize to limitless:

Get-Mailbox -ResultSize limitless

Tip

As talked about to start with, it’s higher to make use of the Get-EXOMailbox cmdlet with Trade On-line. It’s quite a bit quicker then the Get-Mailbox cmdlet. For instance, retrieving 230 mailboxes with Get-Mailbox takes 4.1 seconds and with Get-EXOMailbox solely 2.4 seconds.

Get Inactive or Archive Mailboxes

To get all inactive mailboxes we will use the parameter -InactiveMailboxOnly

Get-Mailbox -InactiveMailboxOnly

And for archive mailboxes, you need to use the parameter -Archive

Get-Mailbox -Archive

Get-Mailbox Properties

The Get-Mailbox cmdlet returns loads of properties, nearly 250! Quite a lot of these properties will not be related in most use instances. We will filter the outcomes by deciding on solely the properties that we’d like, to get you began I’ve a few suggestions/examples for you.

Get-Mailbox -anr adel | Choose DisplayName, PrimarySMTPAddress, RecipientTypeDetails, ProhibitSendReceiveQuota, WhenMailboxCreated, UsageLocation
get-mailbox properties
Get-Mailbox Properties

To get all quotas from a mailbox we will use wildcards within the choose assertion:

Get-Mailbox -Resultsize limitless | Choose displayname, *quota*

# Outcome
ProhibitSendQuota            : 99 GB (106,300,440,576 bytes)
ProhibitSendReceiveQuota     : 100 GB (107,374,182,400 bytes)
RecoverableItemsQuota        : 30 GB (32,212,254,720 bytes)
RecoverableItemsWarningQuota : 20 GB (21,474,836,480 bytes)
CalendarLoggingQuota         : 6 GB (6,442,450,944 bytes)
UseDatabaseQuotaDefaults     : False
IssueWarningQuota            : 98 GB (105,226,698,752 bytes)
RulesQuota                   : 256 KB (262,144 bytes)
ArchiveQuota                 : 100 GB (107,374,182,400 bytes)
ArchiveWarningQuota          : 90 GB (96,636,764,160 bytes)

Export Mailbox data to CSV

The Get-Mailbox cmdlet is commonly used to extract mailbox data from the Trade server. A great way to course of the data additional is to export the outcomes to Excel. We will do that with the Export-CSV possibility. You may merely export any consequence set by piping Export-CSV behind your command:

# Export all mailbox quotas to CSV
Get-Mailbox -Resultsize limitless | Choose displayname, *quota* | Export-CSV -NoTypeInformation

I’ve additionally created a few scripts associated to mailbox data that you just would possibly discover attention-grabbing:

Wrapping Up

Just be sure you additionally take a look at the brand new Trade On-line cmdlets, like Get-EXOMailbox, which supply higher efficiency and are extra dependable than the older cmdlets. For rapidly trying up mailboxes be sure that your attempt the anr parameter.

I hope you discovered this text helpful, you probably have any questions, simply drop a remark under. You may additionally like the next articles:

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments