John Yassa's Blog

Home » Posts tagged 'get-mailbox'

Tag Archives: get-mailbox

Do you know where is your Office 365 mailboxes located ?

I started to get a lot of questions regarding the location of the mailboxes hosted on Office 365 , and where is my tenant is hosted ?

Now we are going to look on how we can know the location of the Tenant and the mailboxes

So to check your tenant location (and mailbox location), open up PowerShell and connect to the Exchange Online Shell

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

Now if you need to know the Location of one mailbox, run the below command

Get-Mailbox -Identity “Mailbox ID” | fl PrimarySmtpAddress,OriginatingServer,OrganizationId

You will get the below result

Org

The Organization ID represents Tenant within EM EA (Starts with EURP)

The Originating server shows that the mailbox is hosted in AM (Amsterdam)

No if you need to get the location of all your mailboxes hosted in Office 365

Get-Mailbox |fl PrimarySmtpAddress,OriginatingServer

The result as below is showing that all mailboxes are hosted in Amsterdam

org2

 

Get mailboxes with mailboxes grater than 1 GB in size

You can run the below command to get the Display Name and the size of the mailbox only and export them to TXT file named result in the path c:\result.txt
get-mailbox -resultsize unlimited | Get-MailboxStatistics | Where {$_.TotalItemSize -Gt 1GB} | Sort-Object -Property TotalItemSize -Descending | Format-Table DisplayName, TotalItemSize >c:\result.txt

You can run the below command to get all the Mailbox info and export them to TXT file named result in the path c:\result.txt
get-mailbox -resultsize unlimited | Get-MailboxStatistics | Where {$_.TotalItemSize -Gt 1GB} | Sort-Object -Property TotalItemSize -Descending | Fl >c:\result.txt

How to remove default mailbox database in Exchange 2010

Most of us as messaging administrators want to delete the default created mailbox database with any new exchange mailbox server

If you tried to delete this default database in normal way you will face the below error
1

So what to do to delete the default database!!!!!!!

below is the steps needed to delete the default database:

  1. Moving Arbitration Mailboxes (System Mailboxes , FederatedEmail) & Discovery mailbox

Get-Mailbox -Arbitration -Database “Mailbox Database 1973945018”
you will get the below result
getarbitration

Now moving this arbitration mailboxes to another DB (MailboxDB) using the below Command
Get-Mailbox -Arbitration -Database “Mailbox Database 1973945018” | New-MoveRequest -TargetDatabase MailboxDB
movearbitration

Now to move the Discovery mailbox , use the Exchange Mangement Console as below
movediscovery

Once all moves are complete, you can remove the move request from the Exchange management console
removemoverequest

2. Move Mailboxes exist on this Mailbox Database

you can do that by the following command :
Get-Mailbox -Database “Mailbox Database 1973945018” | New-MoveRequest -TargetDatabase MailboxDB
movemailboxes

3. Move any archiving mailboxes exist on this DB

Now get all archiving mailboxes and thier corrosponding DBs
Get-mailbox -archive | fl identity,database

Now move these archiving mailboxes to any other DB
Get-Mailbox -Archive | New-MoveRequest -ArchiveTargetDatabase ‘Mailbox Database’ -ArchiveOnly

4. Now you can delete the default Mailbox Database safely without any problem

Find The Total Number Of Mailboxes In Your Domain

How can you quickly find the total number of mailboxes in your Domain? You can do it now by running a shell command.

Get-Mailbox -ResultSize unlimited | Measure-Object

You can further customize the command to your  requirements. Let’s say that you want to find out the mailboxes in one particular database or one particular server. You can find it by adding more switches to the above command. Run the following…

Get-Mailbox –database dbname -ResultSize unlimited | Measure-Object

Get-Mailbox –Server servername -ResultSize unlimited | Measure-Object

Disable “Automatically update e-mail addresses based on email address policy”

If you need to diable the “automatcially update e-mail addresses based on email address policy” option using powershell

1- For 1 user:
Set-mailbox  “MailboxAddress” -EmailAddressPolicyEnabled $false

2- For the whole mailboxes:
Get-mailbox | Set-mailbox  $_.Identity -EmailAddressPolicyEnabled $false

3- For some users within same OU:
Get-mailbox -OrganizationalUnit “OU name”| set-mailbox EmailAddressPolicyEnabled $false

4- For some users with the same domain name:
Get-mailbox -filter {EmailAddresses -like ‘*@Domain.com’} | Set-mailbox  $_.Identity -EmailAddressPolicyEnabled $false

%d bloggers like this: