User & Mailbox Management

Keep record of PowerShell commands

Start-Transcript -Path c:\PS_logfile.txt

Script to Set Database Retention Defaults on all mailboxes

(get-mailbox -resultsize unlimited | Set-Mailbox -UseDatabaseRetentionDefaults $true)

Find Mailbox Rules

Get-InboxRule -Mailbox {User Mailbox}

Get Mailbox Database and Server Information

Get-Mailbox -Identity {User Mailbox} | fl Alias,PrimarySMTPAddress,Database,ServerName

Get Sizes of all Folders in Mailbox

Get-MailboxFolderStatistics “{User Mailbox}” | FL Date, Name, FolderPath, FolderType, ItemsInFolder, DeletedItemsInFolder, FolderSize, ItemsInFolderAndSubfolders, DeletedItemsInFolderAndSubfolders, FolderAndSubfolderSize

Find when Mailbox was Created

get-mailbox -Identity ‘{User Mailbox}’ | fl Name, LinkedMasterAccount,PrimarySMTPAddress,WhenChangedUTC,WhenCreatedUTC

Enable Protocols on Mailbox

Set-CASMailbox -Identity  ‘{User Mailbox}’  -OWAEnabled:$true -POPEnabled:$true -MAPIBlockOutlookRpcHttp:$false -ImapEnabled:$true -MAPIEnabled:$true -ActiveSyncEnabled:$true

Get Mailbox with Attributes

get-mailbox -Identity ‘{User Mailbox}’ | fl Name,DisplayName,alias,LinkedMasterAccount,PrimarySMTPAddress,EmailAddresses,OrganizationalUnit,ServerName,Database,IsMailboxEnabled, CustomAttribute7,CustomAttribute15,ProtocolSettings,ExchangeGuid,RecipientTypeDetails,CustomAttribute1,CustomAttribute2,CustomAttribute3, CustomAttribute4,CustomAttribute5,CustomAttribute6,CustomAttribute7,CustomAttribute8,CustomAttribute9,CustomAttribute10,CustomAttribute11, CustomAttribute12,CustomAttribute13,CustomAttribute14,CustomAttribute15,WhenChangedUTC,WhenCreatedUTC

Get Mailbox with Some Attributes

get-mailbox -Identity ‘{User Mailbox}’ | fl DisplayName,alias,LinkedMasterAccount,PrimarySMTPAddress,EmailAddresses,OrganizationalUnit,ServerName,Database,IsMailboxEnabled,ProtocolSettings, ExchangeGuid,RecipientTypeDetails,CustomAttribute1,CustomAttribute2,CustomAttribute7,CustomAttribute8,CustomAttribute14,CustomAttribute15,WhenChangedUTC,WhenCreatedUTC

Get folder list and type within Mailbox

Get-MailboxFolderStatistics -identity ‘{User Mailbox}’ | FL Name, FolderPath, FolderType

Enable Protocols on Mailbox

Set-CASMailbox -Identity {User Mailbox} -OWAEnabled:$true -POPEnabled:$true -MAPIBlockOutlookRpcHttp:$false -ImapEnabled:$true -MAPIEnabled:$true -ActiveSyncEnabled:$true

Gets Count of how many accounts have Customattribute2 set

(get-mailbox | where {$_.customattribute2 -eq ‘{attribute description}’ }).count

Get Mailbox using ‘ANR’ (ambiguous name)

Get-Mailbox -anr John

Get-Mailbox with customized ‘LinkedMasterAccount’

get-mailbox | where {$_.LinkedMasterAccount -like “S-1-5-21*”}

Get Mailbox Details – Storage usage and Log in times

Get-MailboxStatistics -Identity ‘{User Mailbox}’ | FL DisplayName, StorageLimitStatus, TotalDeletedItemSize, TotalItemSize, ItemCount, LastLoggedOnUserAccount, LastLogoffTime, LastLogonTime

Get Details and Creation, Modified

get-mailbox -Identity ‘{User Mailbox}’ | fl Alias,PrimarySMTPAddress,LinkedMasterAccount,CustomAttribute2,RecipientTypeDetails,Database,ServerName,WhenChangedUTC,WhenCreatedUTC

Get Mailbox Quota

Get-Mailbox -Identity ‘{User Mailbox}’ | Fl *quota

Troubleshooting Mailbox DiskSpace

  • Clear the catalog
  • Move mailboxes found using this
  • get-mailboxdatabase EX10mbx02 | get-mailboxstatistics | Sort TotalItemSize -descending | Select DisplayName, TotalItemSize

Get Details and Creation, Modified (for showing)

get-mailbox -Identity ‘{User Mailbox}’ | fl Alias,PrimarySMTPAddress,LinkedMasterAccount,CustomAttribute2,RecipientTypeDetails,WhenChangedUTC,WhenCreatedUTC

Move Requests in Progress

Get-MoveRequest –MoveStatus InProgress

Use this command to find all non-completed move requests and group them by target database:

Get-MoveRequest | ?{ $_.Status -ne “Completed” -and $_.Status -ne “CompletedWithWarning” } | group targetdatabase | sort Count -Descending

Hide from GAL

Get-Mailbox -identity “{User Mailbox}” | Set-Mailbox -HiddenFromAddressListsEnabled $true

UnHide from GAL

Get-Mailbox -identity “{User Mailbox}” | Set-Mailbox -HiddenFromAddressListsEnabled $false

Gets Target Address

Get-QADUser {user} | Select Name,ProxyAddresses

Create a csv file from Get-MailboxStatistics, but with the TotalItemSize in MB

“DisplayName,TotalItemSize(MB),ItemCount,StorageLimitSize,Database,LegacyDN” | out-file GMS.csv; get-mailbox -resultsize unlimited | Get-MailboxStatistics | foreach{$a = $_.DisplayName;$b=$_.TotalItemSize.Value.ToMB(); $c=$_.itemcount;$d=$_.storagelimitstatus;$e=$_.database;$f=$_.legacydn;”$a,$b,$c,$d,$e,$f”} | out-file name.csv -Append

Get all mailbox sizes

Get-MailboxStatistics  | ft DisplayName, TotalItemSize, ItemCount | where {$_.ObjectClass –eq “Mailbox”}

Get all mailbox sizes and export

Get-MailboxStatistics  | ft DisplayName, TotalItemSize, ItemCount | where {$_.ObjectClass –eq “Mailbox”} > c:\name.txt

Get Mailbox Size for User

Get-MailboxStatistics “{User Mailbox}” | ft DisplayName, TotalItemSize, ItemCount

Out of Office status

Get-MailboxAutoReplyConfiguration {User Mailbox}

Disable Out of Office

Set-MailboxAutoReplyConfiguration {User Mailbox} -AutoReplyState Disabled

Get- Mailbox WITH LIKE command

Get-Mailbox | where {$_.EmailAddresses -like “*{User Mailbox}*”}

Get Mail Contact

Get-MailContact -Identity ‘{User Mailbox}’ | fl DisplayName,ExternalEmailAddress,RecipientType,CustomAttribute2,CustomAttribute5,CustomAttribute6,WhenCreatedUTC,WhenChangedUTC

Get Out of Office Settings

Get-MailboxAutoReplyConfiguration {User Mailbox}

Disable Out of Office Settings

Set-MailboxAutoReplyConfiguration {User Mailbox} -AutoReplyState Disabled

Check Deleted and inbox size

Get-MailboxStatistics -Identity ‘{User Mailbox}’ | fl DisplayName,DeletedItemCount,ItemCount,LastLoggedOnUserAccount,LastLogoffTime,LastLogonTime,LegacyDN, MailboxGuid,ObjectClass,StorageLimitStatus,TotalDeletedItemSize,TotalItemSize,Database, ServerName,DatabaseName,OriginatingServer

Get the current size of the Recoverable Items, Deletions, Purges, Versions

Get-MailboxFolderStatistics “{User Mailbox}” -FolderScope RecoverableItems | Format-List Name,FolderAndSubfolderSize

Get the Disconnected Mailboxes for organization

Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisconnectReason -ne $null} | Sort-Object -Property DisplayName | ft displayname,database,disconnectreason,DisconnectDate -auto

Get ALL Quota Limits for user

Get-Mailbox -IDENTITY “{User Mailbox}” | FL *quota*

Get Archive Mailbox Size for user

get-mailboxstatistics “{User Mailbox}” –archive | FL

Delete email from all users mailboxes

$mbxes = Get-Mailbox -Server  “*SERVER*” -resultsize unlimited

$mbxes | Search-Mailbox -SearchQuery ‘Subject:”*SUBJECT CONTAINS THIS*” Body:”*BODY CONTAINS THIS*”‘ -DeleteContent

If it doesn’t work and it works without the -DeleteContent part then it is a permission issue

If you want to run Search-Mailbox with parameter -DeleteContent, you must be assigned the “Mailbox import Export” Role.

Find the name of all folders in Mailbox
Get-MailboxFolderStatistics -Identity “mailbox alias” | ft Identity | more


Categories: Exchange 2010, Exchange Server

Tags: , , , , , , , , , , ,

We look forward to hearing your feedback..

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: