TechNet - Exchange 2013 cmdlets
TechNet - Exchange 2010 Cmdlets
TechNet - Exchange Management Shell for Exchange 2007 cmdlets.
Michael's meanderings - Exchange Email Address Template Objects in PowerShell
Tested on Exchange Server 2007 and 2013.
For the configured Receive Connectors:
Get-ReceiveConnector | Select-Object Identity,MaxMessageSize,MaxRecipientsPerMessage | Format-Table -AutoSize
For the configured Send Connectors:
Get-SendConnector | Select-Object Identity,MaxMessageSize,SmtpMaxMessagesPerConnection | Format-Table -AutoSize
For the Exchange organization Transport Configuration:
Get-TransportConfig | Select-Object Identity,MaxReceiveSize,MaxRecipientEnvelopeLimit,MaxSendSize | Format-Table -AutoSize
For each Transport Server (use Get-TransportServer for Exchange 2007 and 2010 instead of Get-TransportService):
Get-TransportService | Select-Object Identity,PickupDirectoryMaxRecipientsPerMessage | Format-Table -AutoSize
Tested on Exchange 2007.
Get-MailboxDatabase | Select-Object Identity,ProhibitSendQuota,IssueWarningQuota,ProhibitSendReceiveQuota | Format-Table -Wrap
Tested on Exchange 2007.
Get-Mailbox | Select-Object Name,UseDatabaseQuotaDefaults,ProhibitSendQuota,ProhibitSendReceiveQuota | Where-Object {$_.UseDatabaseQuotaDefaults -eq $false}
Tested on Exchange 2007.
Get-Mailbox | Where-Object { $_.EmailAddressPolicyEnabled -eq $false } | Select-Object DisplayName,ServerName,PrimarySmtpAddress| Format-Table -AutoSize Get-DistributionGroup | Where-Object { $_.EmailAddressPolicyEnabled -eq $false } | Select-Object DisplayName,PrimarySmtpAddress | Format-Table -AutoSize
Tested on Exchange 2007.
Get-Mailbox | Where-Object { $_.HiddenFromAddressListsEnabled -eq $true } | Select-Object DisplayName,HiddenFromAddressListsEnabled | Format-Table -AutoSize Get-DistributionGroup | Where-Object { $_.HiddenFromAddressListsEnabled -eq $true } | Select-Object DisplayName,HiddenFromAddressListsEnabled | Format-Table -AutoSize
Tested on Exchange 2007.
Get-AddressList | Format-Table -AutoSize
Tested on Exchange 2007.
Get-AcceptedDomain | Format-Table -AutoSize
Tested with Exchange 2013.
Use Get-TransportServer instead of Get-TransportService on Exchange 2010.
# The recipient to filter on $strRecipient = "name@domain.com" # Startdate in MM/DD/YYYY format for searching $strStartDate = "11/06/2014" # Name and location of the log file to create $strCsvLogFile = "C:\TEMP\report.csv" # Get results and store in CSV Get-TransportService | Get-MessageTrackingLog -ResultSize Unlimited -Start $strStartDate -Recipient $strRecipient | Select-Object Timestamp,EventId,MessageSubject,Sender,{$_.Recipients},TotalBytes,RecipientCount,ReturnPath | Export-Csv "$strCsvLogFile" -NoTypeInformation
Get-Mailbox | Set-Mailbox -EmailAddressPolicyEnabled $False
Source:Managing E-Mail Address Policies in Exchange Server 2007
Report of all mailboxes on a specific server with total number of items, size in MB, sorted by size:
$strServer = "servername" $strLogFile = "C:\Temp\MailboxSizes.csv" Get-Mailbox -Server $strServer | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select DisplayName, ItemCount, @{name="SizeInMB";expression={$_.TotalItemSize.value.ToMB()}},@{name="DeletedItemSizeInMB";expression={$_.TotalDeletedItemSize.value.ToMB()}} | Export-Csv -Path "$strLogFile" -NoTypeInformation
Source: Comment of GoodThings2Life at EMC - Where are Mailbox Total Items & Size (KB) Columns?
Report of all mailboxes with total number of items, size in MB, sorted by size:
$strLogFile = "C:\Temp\MailboxSizes.csv" Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select DisplayName, ItemCount, @{name="SizeInMB";expression={$_.TotalItemSize.value.ToMB()}},@{name="DeletedItemSizeInMB";expression={$_.TotalDeletedItemSize.value.ToMB()}} | Export-Csv -Path "$strLogFile" -NoTypeInformation
Source: Comment of GoodThings2Life at EMC - Where are Mailbox Total Items & Size (KB) Columns?
Report of all mailboxes with total number of items, size in MB, and mailbox store sorted by size:
Get-MailboxStatistics -server servernaam | Sort-Object TotalItemSize -Descending | Select DisplayName, ItemCount, @{expression={$_.TotalItemSize.value.ToMB()}}, Database | Export-CSV MailboxSizes.csv
Report of all mailboxes under a specific OU with number of items, and size in MB:
Get-Mailbox -OrganizationalUnit "OU=name,DC=domain,DC=local" | foreach {Get-Mailboxstatistics $_ | Sort-Object TotalItemSize -Descending | Select DisplayName, ItemCount, @{expression={$_.TotalItemSize.value.ToMB()}} }|Export-CSV mailboxuse.csv
Get the DisplayName and Mailbox size in MB of alle the mailbox move requests with status “Completed”:
(Get-MoveRequest|Where-Object {$_.Status -eq "Completed"})|ForEach {Get-MailboxStatistics $_.Name}|Select-Object Displayname,@{expression={$_.TotalItemSize.value.ToMB()}}
Tested with Exchange 2007: Get a list of Public Folder permissions starting at a specific folder, examining all folders below and export to CSV:
Get-PublicFolder -Identity "\PublicFolderName" -Recurse | Get-PublicFolderClientPermission | Select-Object identity,user,@{Name = 'AccessRights';Expression = {[string]::join(',',$_.AccessRights)}} | Export-Csv c:\tmp\publicfolderperms.csv
Source for AccessRights expression:·=WugSaJu=· - AccessRights exportados a csv
Tested with Exchange 2007: Add an account with Owner permissions to all Public Folders starting at a specific folder:
Get-PublicFolder -Identity "\PublicFolderName" -Recurse | Add-PublicFolderClientPermission -User username -AccessRights Owner
Tested on Exchange 2007: Report of all mailboxes with name, number of items, total size, and total deleted items size:
Get-MailboxStatistics -server servername | Select DisplayName, ItemCount, @{Name="Total Size in MB";expression={$_.TotalItemSize.value.ToMB()}}, @{Name="Total Deleted Items Size in MB";expression={$_.TotalDeletedItemSize.value.ToMB()}} | Export-CSV c:\temp\MailboxSizes.csv -NoTypeInformation
Tested on Exchange 2007: Report of all public folders with path, number of items, total size, and total deleted items size:
Get-PublicFolderStatistics -server servername -ResultSize Unlimited | Select FolderPath, ItemCount, @{Name="Total Size in MB";expression={$_.TotalItemSize.value.ToMB()}}, @{Name="Total Deleted Items Size in MB";expression={$_.TotalDeletedItemSize.value.ToMB()}} | Sort-Object FolderPath | Export-CSV c:\temp\PublicFolderSizes.csv -NoTypeInformation
On Exchange 2016 (and maybe earlier) the .value.ToMB() no longer works, use this one:
Get-PublicFolderStatistics -ResultSize Unlimited | Select FolderPath, ItemCount, @{Name="Total Size in MB";expression={$_.TotalItemSize.ToMB()}}, @{Name="Total Deleted Items Size in MB";expression={$_.TotalDeletedItemSize.ToMB()}} | Sort-Object FolderPath | Export-CSV c:\temp\PublicFolderSizes.csv -NoTypeInformation
List of all public folders starting at the root folder with name, parentpath, if they are mail enabled, and what kind of content the folder has:
Get-PublicFolder -Identity "\" -Recurse -ResultSize Unlimited | Select-Object Name,ParentPath,Mailenabled,FolderType | Export-CSV c:\temp\PublicFolders.csv -NoTypeInformation
List of all mail enabled public folders with their e-mailaddresses:
Get-MailPublicFolder -ResultSize Unlimited| Select-Object Name,DisplayName,Alias,Identity,WindowsEmailAddress,PrimarySmtpAddress,@{Label="EmailAddresses";Expression={[string]::join(',',$_.EmailAddresses)}} | Export-Csv C:\temp\MailEnabledPublicFolders.csv -NoTypeInformation
Tested on Exchange Server 2010.
Tested on Exchange 2007/2010: Report of all mailboxes with server and SMTP email addresses (skip the X.500 addresses).
$strServer = "ServerName" $strReportFile = "C:\temp\Mailboxes.csv" # For one server Get-Mailbox -Server $strServer | Select-Object Displayname,ServerName,@{Name='EmailAddresses';Expression={[string]::join(";", (($_.EmailAddresses -match "smtp") -Replace "smtp:",""))}} | Export-Csv "$strReportFile" -NoTypeInformation # For all servers Get-Mailbox | Select-Object Displayname,ServerName,@{Name='EmailAddresses';Expression={[string]::join(";", (($_.EmailAddresses -match "smtp") -Replace "smtp:",""))}} | Export-Csv "$strReportFile" -NoTypeInformation
Source:Exchange Server Share - PowerShell: Export Multivalued Properties
Set-Mailbox User1 -EmailAddresses @{Add='TestUser1@domain.com’}
Source: Shay Levy - Managing email addresses in Exchange 2010 via Mike Pfeiffer's Blog - Quickly Add an Email Address to an Exchange Mailbox using PowerShell
New-DynamicDistributionGroup -Name "All janitors" -Alias "All-janitors" -OrganizationalUnit "domain.local/Distribution Lists" -RecipientFilter {(RecipientType -eq 'UserMailbox')} -RecipientContainer "domain.local/Janitors"
Sadly the following doesn't work (see the KB296112 link):
New-DynamicDistributionGroup -Name "All users with mailbox (except janitors)" -Alias "All-users-with-mailbox-except-janitors" -OrganizationalUnit "domain.local/Distribution Lists" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (DistinguishedName -notlike 'OU=Janitors,DC=domain,DC=local')} -RecipientContainer "domain.local"
Sources:
Microsoft Support - Cannot use an organizational unit or the location of an account for recipient policy (KB296112)
Microsoft TechNet - Exchange 2007 - Creating Filters in Recipient Commands
Microsoft TechNet - Exchange 2007 - Filterable Properties for the -RecipientFilter Parameter in Exchange 2007 SP1 and SP2
Microsoft TechNet - Exchange 2010 - New-DynamicDistributionGroup
Tested on Exchange Server 2007 and 2010.
Get-Mailbox -ResultSize Unlimited | ` Where-Object {$_.GrantSendOnBehalfTo -ne $null} | ` Select-Object Name,@{Name='GrantSendOnBehalfTo';Expression={[string]::join(";", ($_.GrantSendOnBehalfTo))}}
Tested on Exchange Server 2010.
$strUser = "username" Get-Mailbox | Get-MailboxPermission | Where-Object {$_.User -match "$strUser"} | Format-Table -AutoSize
Only shows access granted by an administrator on the Exchange mailbox level.
Tested with Exchange Server 2010.
Get-mailbox | ` Get-MailboxPermission | ` Where-Object {$_.IsInherited -ne "True"} | ` Select-Object ` Identity,User, @{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}},InheritanceType | ` Sort-Object Identity | ` Export-Csv -Path C:\Temp\result.csv -NoTypeInformation
Same, but filter on accounts whose Displayname starts with User1:
Get-mailbox | ` Where-Object {$_.DisplayName -match "User1*"} | ` Get-MailboxPermission | ` Where-Object {$_.IsInherited -ne "True"} | ` Select-Object ` Identity,User, @{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}},InheritanceType | ` Sort-Object Identity | ` Export-Csv -Path C:\Temp\result.csv -NoTypeInformation
Tested on Exchange Server 2010.
Get-mailbox | ` Get-MailboxPermission | ` Select-Object ` Identity,User, @{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}},InheritanceType,IsInherited,Deny | ` Sort-Object Identity | ` Export-Csv -Path C:\Temp\result.csv -NoTypeInformation
Active Directory side (for SendAs permission) for a specific mailbox (User1):
Get-ADPermission -Identity User1 | ` Select-Object Identity, User, @{Name="AccessRights";Expression={[string]::join(";",$_.AccessRights)}}, @{Name="ExtendedRights";Expression={[string]::join(";",$_.ExtendedRights)}}, InheritanceType, IsInherited, Deny | ` Export-Csv -Path C:\Temp\result.csv -NoTypeInformation
All AD accounts with SendAs granted to another user:
foreach ($objUser in $(Get-ADUser -Filter *)) { Get-AdPermission -Identity $objUser.Name | ` Where-Object {$_.ExtendedRights -match "Send" -And $_.User -notmatch "SELF" -And $_.User -notmatch "^S-1-5"} | ` Select-Object Identity,User,AccessRights,ExtendedRights }
Export all AD accounts with SendAs granted to another user to C:\Temp\YYYY-MM-DD-SendAs.csv:
$objPermissions = @() foreach ($objUser in $(Get-ADUser -Filter *)) { $objTemp = Get-AdPermission -Identity $objUser.Name | ` Where-Object {$_.ExtendedRights -match "Send" -And $_.User -notmatch "SELF" -And $_.User -notmatch "^S-1-5"} | ` Select-Object Identity,User,@{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}},@{Name="ExtendedRights";Expression={[string]::join(";", ($_.ExtendedRights))}} $objPermissions += $objTemp } $objPermissions | Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-SendAs.csv
All mailboxes with GrantSendOnBehalfTo granted to another user:
Get-Mailbox | ` Where-Object {$_.GrantSendOnBehalfTo -ne $null} | ` Select-Object Name,@{Label="GrantSendOnBehalfTo";Expression={$_.GrantSendOnBehalfTo.Name}} | ` Sort-Object Name | ` Format-Table -AutoSize
Export all mailboxes with GrantSendOnBehalfTo granted to another user to C:\Temp\YYYY-MM-DD-SendOnBehalfTo.csv:
Get-Mailbox | ` Where-Object {$_.GrantSendOnBehalfTo -ne $null} | ` Select-Object Name,@{Label="GrantSendOnBehalfTo";Expression={$_.GrantSendOnBehalfTo.Name}} | ` Sort-Object Name | ` Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-SendOnBehalfTo.csv
List all mailboxes where an unresolvable SID (deleted account/group/object) still has permissions:
Get-Mailbox | Get-MailboxPermission | Where-Object {$_.User -match "^S-1-5"} | Format-Table -AutoSize
Export all non-inherited mailbox permissions to C:\Temp\YYYY-MM-DD-MailboxPermissions.csv:
Get-Mailbox | ` Get-MailboxPermission | ` Where-Object {$_.IsInherited -eq $False -And $_.User -notmatch "SELF" } | ` Select-Object Identity,User,@{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}} | ` Sort-Object Identity | ` Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-MailboxPermissions.csv
See also:
Mailbox permissions:
Get-EXOMailbox | ` Get-EXOMailboxPermission | ` Where-Object {$_.IsInherited -eq $False -And $_.User -notmatch "SELF" } | ` Select-Object Identity,User,@{Name="AccessRights";Expression={$_.AccessRights -join ";"}} | ` Sort-Object Identity | ` Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-MailboxPermissions.csv
SendOnBehalf:
Get-EXOMailbox -Properties GrantSendOnBehalfTo | ` Where-Object {$_.GrantSendOnBehalfTo -ne $null} | ` Select-Object Name,@{Label="GrantSendOnBehalfTo";Expression={$_.GrantSendOnBehalfTo}} | ` Sort-Object Name | ` Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-SendOnBehalfTo.csv
SendAs:
Get-EXORecipientPermission | ` Where-Object {$_.IsInherited -eq $False -And $_.Trustee -notmatch "SELF" } | ` Select-Object Identity,Trustee,@{Name="AccessRights";Expression={[string]::join(";", ($_.AccessRights))}} | ` Sort-Object Identity | ` Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-RecipientPermissions.csv
Tested on Exchange Server 2010, and 2013.
$strMailbox = "Mailbox name" $strPermissionsFor = "User or group" # Add mailbox full access permissions. Add-MailboxPermission -Identity "$strMailbox" -User "$strPermissionsFor" -InheritanceType All -AccessRights FullAccess # Add Send As permissions. Add-ADPermission -Identity "$strMailbox" -User "$env:USERDOMAIN\$strPermissionsFor" -Extendedrights "Send As"
Office 365 / Exchange Online version:
$strMailbox = "Mailbox name" $strPermissionsFor = "User or group" # Add mailbox full access permissions. Add-MailboxPermission -Identity "$strMailbox" -User "$strPermissionsFor" -InheritanceType All -AccessRights FullAccess # Add Send As permissions. Add-RecipientPermission -Identity "$strMailbox" -Trustee "$strPermissionsFor" -AccessRights SendAs
Source: o365info.com - Manage Send As Permissions using PowerShell – Office 365
Tested on Exchange Server 2019.
First try the Dutch “Agenda” if that fails, try the default “Calendar”.
$objMailboxes = Get-Mailbox | Sort-Object Name $objResult = @() foreach ($objMailbox in $objMailboxes) { Write-Host $($objMailbox.Name) try { $objPerms = Get-MailboxFolderPermission -Identity "$($objMailbox.Name):\Agenda" -ErrorAction Stop } catch { $objPerms = Get-MailboxFolderPermission -Identity "$($objMailbox.Name):\Calendar" } foreach ($objPerm in $objPerms) { $objTemp = {} | Select-Object Name,Folder,User,AccessRights $objTemp.Name = $objMailbox.Name $objTemp.Folder = $objPerm.FolderName $objTemp.User = $objPerm.User $objTemp.AccessRights = [string]::join(" + ", ($objPerm.AccessRights)) $objResult += $objTemp } } $objResult | Export-Csv -NoTypeInformation -Path C:\Temp\$((Get-Date -Format u).SubString(0,10))-CalendarFolderPermissions.csv