How to Create a Remote Mailbox using Exchange Management Shell

Use below command to create remote mailbox, it will also create AD account.

New-RemoteMailbox -Name “UserADName” -DisplayName “UserDisplayName” -UserPrincipalName  “UserUserPrincipalName” -Alias “UserAlias” -PrimarySmtpAddress “UserPrimarySMTPAddress” -OnPremisesOrganizationalUnit “UserOUContainerPath” -FirstName “FirstName” -LastName “UserLastName”

In case User already exist in AD and Remote Mailbox Needed to enable, use below command:

Enable-RemoteMailbox -Identity “UserSAMAccountName” -Alias “UserAlias” -RemoteRoutingAddress Alias@O365DomainName.mail.onmicrosoft.com -PrimarySmtpAddress “UserPrimarySMTPAddress”

Wondering how many log files are generated per server every minute? Quickly find out by typing below Exhcange power shell

Get-MailboxDatabase -Server $env:ComputerName | ?{ %{$_.DatabaseCopies | ?{$_.ReplayLagTime -ne [TimeSpan]::Zero -And $_.HostServerName -eq $env:ComputerName} }
} | %{ $count = 0; $MinT = [DateTime]::MaxValue; $MaxT = [DateTime]::MinValue; Get-ChildItem -Path $_.LogFolderPath -Filter “*????.log” | %{ $count = $count + 1;
if($_.LastWriteTime -gt $MaxT){ $MaxT = $_.LastWriteTime}; if($_.LastWriteTime -lt $MinT){ $MinT= $_.LastWriteTime} }; ($count / ($MaxT.Subtract($MinT)).TotalMi
nutes) } | Measure-Object -Min -Max -Ave

How to Change UPN in O365 for a Mailbox User

There is only one way you can do it while running the exchange and O365 hybrid mode. this is not directly possible but you need to first change this to intermediate UPN and then to the required UPN as below 2 power shell commands:

Let say you want to change UPN for a user user@domain.net to user@domain.com,

Set-MsolUserPrincipalName -UserPrincipalName user1@domain.net -NewUserPrincipalName user1@domain.onmicrosoft.com
Set-MsolUserPrincipalName -UserPrincipalName user1@domain.onmicrosoft.com -NewUserPrincipalName user1@domain.com

 


Set-MailboxCalendarSettings cmdlet to enable calendar processing for a mailbox.

Use the Set-MailboxCalendarSettings cmdlet to enable calendar processing for a mailbox.

The Set-MailboxCalendarSettings cmdlet lets you enable calendar processing for a mailbox. You can configure parameters for automatic resource booking or Calendar Attendant processing.

To run the Set-MailboxCalendarSettings cmdlet, the account that you use must be delegated the following:

-Exchange Organization Administrator role

Set-MailboxCalendarSettings -Identity “5th Floor Conference Room” -AutomateProcessing AutoAccept -AddOrganizerToSubject $true -DeleteSubject $true

Exchange Server 2010 – Changing Message Tracking Log Retention Period

Open the Exchange Management Shell console and determine your server’s identity and verify logging is enabled with either of these commands.

Get-TransportServer | Select Name,MessageTrackingLogEnabled | ft -auto
Get-MailboxServer | Select Name,MessageTrackingLogEnabled | ft -auto
Here you can check the current Message Logging values. It also aids in determining which switches to set.

Get-MailboxServer YourServerName | fl messagetracking*

You should see something like this…

MessageTrackingLogEnabled : True
MessageTrackingLogMaxAge : 30.00:00:00
MessageTrackingLogMaxDirectorySize : 1000 MB (1,048,576,000 bytes)
MessageTrackingLogMaxFileSize : 10 MB (10,485,760 bytes)
MessageTrackingLogPath : C:\Program Files\Exchange\TransportRoles\Logs\MessageTracking
MessageTrackingLogSubjectLoggingEnabled : True

Change your values to something more useful. In my case, space was not an issue so I enabled logging for 365 days and allocated 10 GB for log files.

Set-TransportServer YourServerName -MessageTrackingLogMaxAge 365
Set-TransportServer YourServerName -MessageTrackingLogMaxDirectorySize 10000MB

This command spins through all your mailbox servers and reconnects all the uniquely identified but disconnected mailboxes in any one of the mailbox stores:

$Servers = Get-ExchangeServer
$Servers | `
  Where { $_.IsMailboxServer -Eq ‘$True’ } `
  | ForEach { Get-MailboxStatistics -Server $_.Name `
  | Where { $_.DisconnectDate -NotLike ” } `
  | ForEach { Connect-Mailbox -Identity `
    $_.DisplayName -Database $_.DatabaseName} }

Wondering how many log files are generated per server every minute? Quickly find out by typing:

 

Get-MailboxDatabase -Server $env:ComputerName | ?{ %{$_.DatabaseCopies | ?{$_.ReplayLagTime -ne [TimeSpan]::Zero -And $_
.HostServerName -eq $env:ComputerName} } } | %{ $count = 0; $MinT = [DateTime]::MaxValue; $MaxT = [DateTime]::MinValue;
Get-ChildItem -Path $_.LogFolderPath -Filter “*????.log” | %{ $count = $count + 1; if($_.LastWriteTime -gt $MaxT){ $MaxT
= $_.LastWriteTime}; if($_.LastWriteTime -lt $MinT){ $MinT= $_.LastWriteTime} }; ($count / ($MaxT.Subtract($MinT)).Tota
lMinutes) } | Measure-Object -Min -Max -Ave

How to Count Number of Mailboxes in Exchange 2010 Using Powershell

Command to count all type of mailboxes in Exchange Management Shell

Get-Mailbox -ResultSize Unlimited | measure-object

Command to count Specific type of mailboxes in Exchange Management Shell

Get-Mailbox -ResultSize Unlimited | where {$_.ResourceType -eq “Equipment”} | measure-object

Command to count mailboxes on a specific server in Exchange Management Shell

Get-Mailbox -ResultSize Unlimited | where {$_.ServerName -eq “SERVERNAME”} | measure-object