Showing posts with label Exchange. Show all posts
Showing posts with label Exchange. Show all posts

POWERSHELL: Get infomation about email queue message counts

Quik check of all active Hub Transport queues:
$HubTransports=Get-ExchangeServer | Where {$_.ServerRole -like "*Hub*"}
$HubTransports| foreach {
 Get-Queue|ft }

Quik check of all active Hub Transport queues with a message count of 5 or more:
$HubTransports=Get-ExchangeServer | Where {$_.ServerRole -like "*Hub*"}
$HubTransports | foreach {
 Get-Queue -Filter {MessageCount -ge 5}}

POWERSHELL: List DL <> User Memberships (with a one-to-one mapping)

$dist = ForEach ($group in (Get-DistributionGroup -ResultSize Unlimited -Filter {name -like "*"})) 
   { Get-DistributionGroupMember $group -ResultSize Unlimited | Select @{Label="Group";Expression={$Group.Name}},@{Label="User";Expression={$_.Name}},SamAccountName,@{Label="Organizational Unit";Expression={$_.OrganizationalUnit}}  
   }
$dist | Sort Group,User | Export-CSV User2DL_Inventory.csv -NoTypeInformation

POWERSHELL: Finding a Public Folder by Email Address

Get-MailPublicFolder >email address here< | get-publicfolderstatistics | `
Select-Object Name, AdminDisplayName, FolderPath, LastAccessTime

Exchange: Delete messages from within mailboxes in Exchange 2010

Build necessary roles:
New-RoleGroup -Name "Exchange Mailbox Import Export" -Roles "Mailbox Import Export" `
-Members "admin" -DisplayName "Exchange Mailbox Import Export" `
-Description "This group will provide access to mailbox import and export cmdlets 
within entire Exchange Organization."
 
New-RoleGroup -Name "Exchange Support Diagnostics" -Roles "Support Diagnostics" `
-Members "admin" -DisplayName "Exchange Support Diagnostics" `
-Description "This group will provide access to support diagnostics cmdlets 
within entire Exchange Organization."

Ensure roles membership is correct (the user executing the deletion needs to be a member if these groups):
Get-RoleGroupMember -Identity "Discovery Management"

Get-RoleGroupMember -Identity "Exchange Mailbox Import Export"

Get-RoleGroupMember -Identity "Exchange Support Diagnostics"
Run message search (example):
Search-Mailbox -Identity 'user' -SearchQuery "Received: > $('01/1/2014 00:00:00') `
AND Received: < $('01/1/2014 23:59:59') `
AND Subject:Deletethis" -LogLevel Full -TargetMailbox 'Discovery Search Mailbox' `
-TargetFolder 'Search Results'
Delete messages from all mailboxes(example):
Get-Mailbox -ResultSize Unlimited | Select-Object SamAccountName | out-file mailboxusers.txt

$mailboxusers = Get-Content .\mailboxusers.txt

foreach ($user in $mailboxusers) {Search-Mailbox -Identity $user -SearchQuery "Received: > $('10/31/2014 00:00:00') `
AND Received: < $('10/31/2014 23:59:59') `
AND FROM:problematic@sender.com" -LogLevel Full -TargetMailbox 'Discovery Search Mailbox' `
-TargetFolder 'Search Results - problematic search' –DeleteContent -Force}

Outlook 2010: Complete Exchange AutoDiscover Wizard In The Background Without User Intervention

Run the autodiscover wizard in the background without asking the user to click next next finish to configure and create the outlook profile by adding the following registry key to the client:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\Outlook\AutoDiscover
Value name: ZeroConfigExchange
Value type: REG_DWORD
Value data: 1

- OR -

If you want to do this using a GPO group policy object, enable this Outlook 2010 Policy on your domain:
User configuration / Policies / Administrative templates / Microsoft Outlook 2010 / Account Settings / Exchange
“Automatically configure profile based on Active Directory Primary SMTP address”

Powershell: Recursively Set Outlook Folder Permissions using Powershell

Get-MailboxFolderStatistics

Obtain a list of folders to apply permissions. The result is the FolderPath value that is returned in the format "/Folderpath".

Get-MailboxFolderStatistics owner | `
 Where { $_.FolderPath.Contains("FolderName") -eq $true }

Add-MailboxFolderPermission or Remove-MailboxFolderPermission

Use the Add-MailboxFolderPermission or Remove-MailboxFolderPermission cmdlets to assign (remove) permissions from a set of folders. The format for the folder name is "Mailbox:FolderPath" so you need to modify the result from earlier to accommodate the expected value.

The following example illustrates the example where Rose, Juanita and Lupe's manager (Hector) wants to grant these users access to his "Work" folder and all of its sub-folders.

$targetmailbox="Hector"

#Reset Permissions
cls
$targetmailbox="mailbox_name"
ForEach($f in (Get-MailboxFolderStatistics $targetmailbox | Where { $_.FolderPath.Contains("Inbox") -eq $true })) {
 $fname = $targetmailbox + ":" + $f.FolderPath.Replace("/","\");
 $userlistArray = @()
 #Purge existing permsissions and set defaults
 ForEach($g in (Get-MailboxFolderPermission $fname | select User,AccessRights)) {
  if ($g.User -like "NT User:domain\*") { 
   Remove-MailboxFolderPermission $fname -User $g.User -confirm: $false
  }
  elseif ($g.User -like "Default") {
   Set-MailboxFolderPermission $fname -User $g.User -AccessRights Author
  }
  elseif ($g.User -notlike "Default") {
   Remove-MailboxFolderPermission $fname -User $g.User -confirm: $false
  }
 }
 #Set owner permissions (modify users and rights to assign other permission values to specific users)
 $user=("Rose","Juanita","Lupe")
 ForEach ($targetuser in $user){
  Add-MailboxFolderPermission $fname -User $targetuser -AccessRights Owner
 }
}

#Report Permissions
cls
$targetmailbox="mailbox_name"
ForEach($f in (Get-MailboxFolderStatistics $targetmailbox | Where { $_.FolderPath.Contains("Inbox") -eq $true })) {
 $fname = $targetmailbox + ":" + $f.FolderPath.Replace("/","\");
 write-host $fname -BackgroundColor "Green" -ForegroundColor "Black"
 $userlistArray = @()
 ForEach($g in (Get-MailboxFolderPermission $fname | select User,AccessRights)){
  if ($g.User -like "NT User:domain\*") { 
   write-host " " $g.User ":" $g.AccessRights -BackgroundColor "Red" -ForegroundColor "Black"
  }
  elseif ($g.User -like "Default") { 
   write-host " " $g.User ":" $g.AccessRights -BackgroundColor "White" -ForegroundColor "Black"
  }
  elseif ($g.User -notlike "Default") { 
   write-host " " $g.User ":" $g.AccessRights
  }
 }
}

Emailology: Two Ways to Ensure that Your Entire Email Is Rendered by Default in the iPhone & iPad

Problem:
I have some email based reports, which have various embedded images and tables. All display fine on iPhone. However, once they get beyond a certain (quite limited) size, they display as raw text. To view the email properly the user must scroll to the bottom and tap 'download full message' before it looks like it should.
Is there any way to encourage ios to download the entire message so it displays as Html immediately?
Notes:  After troubleshooting this (on a 3G network, on WiFi, with different size emails), my conclusion, is that this is not a fixed message size limitation, but something a bit more intelligent.

As I understand this, the iPhone iOS appears to detect your current network speed, the speed of the server from which any resources are being served and calculates the total size of the email. If iPhone iOS determines rendering the email is going to take what it considers a long time (I haven't been able to work out an exact number), then it gives you the plain text formatted message. I imagine, this is presented in plain text formatting as the html source code (if only partially downloaded) would be incomplete (missing style sheets, tags, etc.) and the message would be utter gibberish.

Objective:  Ensure that your entire email is rendered by default in the iphone & ipad

Solution (there are a few ways to resolve this):

  • Short messages, more text, fewer images, smaller attachments
  • Images/attachments compressed as much as possible
  • If a user is presented with a plain text version of this email, simply scroll to the end/bottom of the message and click “download full message”

Exchange: Allow an unauthenticated user to relay mail using Exchange 2010

Problem: I have this application/website that needs to send emails, I have it configured to use our exchange server as SMTP. It can send emails to internal users however external ones are failing with a "550 5.7.1 Unable to relay" error.

Note: This SHOULD be done by establishing an authenticated relationship - yet, there are time when an application has limitations and is unable to pass login credentials.

Objective: Allow an unauthenticated user to relay mail using Exchange 2010

Solution:
New-ReceiveConnector -Name RELAYCONNECTOR -usage Custom -Bindings '1.1.1.1:25' -fqdn mailservername.domain.com -RemoteIPRanges 2.2.2.2 -server mailservername -permissiongroups AnonymousUsers
Get-ReceiveConnector RELAYCONNECTOR | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"

Exchange: Find All Disabled User Accounts NOT Hidden From the Address Book

Objective: list all disabled user accounts NOT hidden from the Global Address Book
Get-Mailbox -Filter{(HiddenFromAddressListsEnabled -eq $false) -AND (UserAccountControl -eq "AccountDisabled, NormalAccount")}

Exam 70-663: Designing and Deploying Messaging Solutions with Microsoft Exchange Server 2010


Design the Exchange Server 2010 installation
Planning Roadmap for New Deployments: Exchange 2010 SP1 Help
Understanding Disjoint Namespace Scenarios: Exchange 2010 SP1 Help
Understanding Federation: Exchange 2010 SP1 Help
Exchange 2010 Architecture Poster
Planning to Use Active Directory Sites for Routing Mail: Exchange 2010 SP1 Help
Exchange Scale Limitations spreadsheet

Design message routing
Understanding Transport: Exchange 2010 SP1 Help
Understanding Accepted Domains: Exchange 2010 SP1 Help
Understanding Remote Domains: Exchange 2010 SP1 Help
Understanding Shadow Redundancy: Exchange 2010 SP1 Help
Understanding Exchange Performance: Exchange 2010 SP1 Help
Understanding Server Role Ratios and Exchange Performance: Exchange 2010 SP1 Help
Understanding Foreign Connectors: Exchange 2010 SP1 Help

Design the mailbox server role
Mailbox Server Storage Design: Exchange 2010 SP1 Help
Exchange 2010 Cross-Forest Mailbox Moves
Understanding Mailbox: Exchange 2010 SP1 Help
Exchange 2010 Large Mailbox Vision (Whitepaper)
Exchange 2010 Mailbox Server Role Requirements Calculator

Design Client Access
Understanding Client Access: Exchange 2010 SP1 Help
Understanding the Relative Costs of Client Access Server Workloads in Exchange Server 2010
Exploring Exchange 2010 RPC Client Access service

Plan for transition and coexistence
Exchange 2003 - Planning Roadmap for Upgrade and Coexistence: Exchange 2010 SP1 Help
Exchange 2007 - Planning Roadmap for Upgrade and Coexistence: Exchange 2010 SP1 Help
Why Migrations Instead of In-Place Upgrades?
Common Client Access Considerations for Outlook 2003 and Exchange 2010

Prepare the infrastructure for Exchange Server 2010 deployment
Planning Active Directory: Exchange 2010 SP1 Help

Deploy Edge Transport Server role
Deploy the Edge Transport Server Role in an Existing Exchange 2003 Organization Before Upgrading to Exchange 2010: Exchange 2010 SP1 Help

Deploy Client Access Server role
Installation Guide Template - Client Access Server: Exchange 2010 SP1 Help

Deploy Hub Transport Server role
Installation Guide Template - Hub Transport Server: Exchange 2010 SP1 Help
Microsoft Exchange Server 2010 Transport Server Role Architecture Diagrams

Deploy Mailbox Server role
Installation Guide Template - Mailbox Server: Exchange 2010 SP1 Help
Installation Guide Template - DAG Member: Exchange 2010 SP1 Help
Understanding Address Lists: Exchange 2010 SP1 Help
Understanding Offline Address Books: Exchange 2010 SP1 Help
Understanding Public Folders: Exchange 2010 SP1 Help

Deploy server roles for coexistence and migration
Configuring inter-org Free/Busy lookups for Exchange 2007 mailboxes in an Exchange 2010 SP1 federated organization
Understanding Upgrade from Exchange 2003 to Exchange 2010: Exchange 2010 SP1 Help
Understanding Upgrade from Exchange 2007 to Exchange 2010: Exchange 2010 SP1 Help
Upgrade Custom LDAP Filters to OPATH Filters: Exchange 2010 SP1 Help
Create Additional Routing Group Connectors from Exchange 2010 to Exchange 2003: Exchange 2010 SP1 Help
Suppress Link State Updates: Exchange 2010 SP1 Help
Management Tool Interoperability
Upgrading Exchange ActiveSync to Exchange 2010
Upgrading Outlook Web App to Exchange 2010
Transitioning Client Access to Exchange 2010


Exam 70-662: Microsoft Exchange Server 2010, Configuring

Recommended Reading:


Configuring Exchange Recipients and Public Folders (14 percent)


Configuring Client Access (15 percent)

Configuring Message Transport (15 percent)
Understanding Transport: Exchange 2010 Help


Monitoring and Reporting (13 percent)
Monitoring Exchange 2010: Exchange 2010 Help

Configuring Message Compliance and Security (13 percent)

Powershell: Gain Visibility of Mobile Devices within Your Exchange ActiveSync Environment

In the era of Bring Your Own Device (BYOD), more users than ever are connecting to Exchange through ActiveSync without ITs knowledge.

You can easily view all of the devices connecting to your Exchange servers through ActiveSync. The following identify the number ActiveSync device associations and exports mailbox and device information for reporting and maintenance.

List this:
$devicelist = @()
$userlist=Get-CASMailbox -results unlimited | where {$_.ExchangeVersion -like "*14*"} | select name,samaccountname
Run this:
$userlist | foreach {
 $name=$_.name;
 $device = get-ActiveSyncDeviceStatistics -mailbox $_.samaccountname;
 $device | foreach { 
  $devicelist += ($_ | select-object @{Name="Name";Expression={"$name"}},DeviceType,DeviceID,DeviceFriendlyName,DeviceModel,DeviceUserAgent, `
  DeviceOS,IsRemoteWipeSupported,NumberOfFoldersSynced)} }
$devicelist | Out-GridView

Creating Scheduled Tasks for Exchange 2010 PowerShell Scripts

Use the following command syntax to schedule an Exchange powershell script. You need to tell PowerShell to load the Exchange Management Shell environment before executing your script. This will give you access to all of the cmdlets, variables and functions that are loaded with Exchange Management Shell. To schedule a powershell script, consider the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -nologo -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; 
Connect-ExchangeServer -auto; 
c:\Scripts\script.ps1"

If you don't want to use a powershell script you can embed your code within this parameter. You might find this method useful for short scripts or one-liners. For example, to list the databases mounted on a specific server, consider the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -nologo -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; 
Connect-ExchangeServer -auto; 
Get-MailboxDatabase | where {$_.Server -eq "mailserver"}

To schedule PowerShell scripts one would not require Exchange tools installed locally - PowerShell v2 is necessary, though. Use implicit remoting to import the Exchange Management Shell cmdlets from a specific server. Consider the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -nologo -command "$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://fab-ex2.fabrikam.local/PowerShell/ -Authentication Kerberos;
Import-PSSession $s;
Get-MailboxDatabase | where {$_.Server -eq "mailserver"}

Powershell: Manage OOTO

To get the existing Out of Office/Auto Reply settings for a specific user:
Get-MailboxAutoReplyConfiguration "user"

Which should return something similar to this:
RunspaceId       : 557b047e-4a9e-4852-86b9-dff1d2072082
AutoReplyState   : Scheduled
EndTime          : 7/2/2012 8:00:00 AM
ExternalAudience : All
ExternalMessage  : I am out of the office and will return on Monday, July 2.
InternalMessage  : I am out of the office and will return on Monday, July 2. I will have LIMITED access to email. If you need assistance, please contact "different user" (ext. ####).
StartTime        : 6/27/2012 5:00:00 PM
MailboxOwnerId   : domain.local/Users and Computers/IT/user
Identity         : domain.local/Users and Computers/IT/user
IsValid          : True

Disable Out of Office/Auto Reply and clear the Internal/External message:
Set-MailboxAutoReplyConfiguration -identity "user" -AutoReplyState disabled -InternalMessage "" -ExternalMessage ""

Set auto reply settings for a mailbox:
Set-MailboxAutoReplyConfiguration -identity "user" -AutoReplyState enabled -InternalMessage "message" -ExternalMessage "message"

Set a scheduled auto reply settings for a mailbox:
Set-MailboxAutoReplyConfiguration -identity "user" `
-AutoReplyState Scheduled -StartTime "6/27/2012 17:00:00" -EndTime "7/2/2012 8:00:00" -InternalMessage  "I am out of the office and will return on Monday, July 2.  I will have LIMITED access to email.  If you need assistance, please contact "different user" (ext. ####)." `
-ExternalMessage  "I am out of the office and will return on Monday, July 2." 

To get a list of all currently enabled Out of Office/Auto Reply (for active accounts which have logged in within the past 90 days):
$3Months = Get-Date
$3Months = $3Months.AddMonths(-3)
Get-exchangeserver | ?{$_.ServerRole -eq "Mailbox"} | `
Get-mailbox -results Unlimited | ?{$_.OrganizationalUnit -notlike "*disabled*"} | `
Get-MailboxStatistics | ?{$_.LastLogonTime -lt $3Months} | `
Get-MailboxAutoReplyConfiguration | ?{$_.AutoReplyState -eq "Enabled"} | `
select Identity,EndTime | ft -auto

Active Directory Error While Moving Mailboxes

Error:
Active Directory operation failed on dcserver.domain.com. This error is not retriable. Additional information: Insufficient access rights to perform the operation.
Active directory response: 00002098: SecErr: DSID-03150A48, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0

Solution:
From a domain controller with the same site as your exchange server, open ADUC. Once inside of AD, make sure you go to View and select the Advanced View. Search for the user, go to Properties, Security, and then click on Advanced. Click the check box to Include Inheritable permissions from this object’s parent. Allow 2-3 minutes for replication and then go through the mailbox move again. All Set!

Powershell - Stop All Exchange Services

# Stop MSExchangeADTopology Dependent services
foreach ($svc in get-service MSExchangeADTopology) {$dep = $svc.dependentservices}
foreach ($aa in $dep)
{
get-service $aa.Name | select Name,status
stop-service $aa.Name
get-service $aa.Name | select Name,status
}

# Stop all services with the name Exchange
$svcstatus = get-service *exchange* | select name,status
foreach ($mystatus in $svcstatus -eq "Running") {$mystatus = $svcstatus.Status}
foreach ($ab in $svcstatus)
{
get-service $ab.Name | select Name,status
stop-service $ab.Name -f
get-service $ab.Name | select Name,status
}

Powershell - Removing Unused Distribution Lists In The Exchange 2010

We currently have over 900 Distribution Lists (DLs) within our mail environment – many of which we have believe to be unused/orphaned.  I have tested the following steps in an effort to automate a task which could be scheduled (every 90 days?) to identify and remove unused DLs in our Exchange 2010 environment.

Steps:
  1. Increase Exchange MessageTrackingLogs from the default of 30 days (1Gb) to 90 days (3Gb)
  2. Export list of ALL DLs
  3. Export list of ALL active DLs based off Exchange Tracking Logs
  4. Compare the results and output the inactive DLs
  5. Hide all unused DLs from the GAL
  6. Delete all unused DLs from Exchange
Notes:
  • Note these are server specific commands and I need to do this on all hub transport servers
  • Increasing the log will not remove the original logs
  • We will have to wait 2 months after setting these logs up
Ref:
Configure Message Tracking (http://technet.microsoft.com/en-us/library/aa997984.aspx)

1. Configuring Exchange MessageTrackingLogs settings
Get-TransportServer | fl name,*messagetracking*

 Get-TransportServer | `
  Set-TransportServer -MessageTrackingLogMaxDirectorySize 3072MB `
  -MessageTrackingLogMaxAge 180.00:00:00
  
 Get-TransportServer | fl name,*messagetracking*
2. Export list of ALL DLs
Get-DistributionGroup -ResultSize Unlimited | `
  Select-Object PrimarySMTPAddress | `
  Sort-Object PrimarySMTPAddress | `
  Export-CSV DL-ALL_Present_Tense.csv -notype
3. Export list of ALL active  DLs based off Exchange Tracking Logs
Get-TransportServer | `
  Get-MessageTrackingLog -EventId Expand -ResultSize Unlimited | `
  Sort-Object RelatedRecipientAddress | `
  Group-Object RelatedRecipientAddress | `
  Sort-Object Name | `
  Select-Object @{label="PrimarySmtpAddress"; `
  expression={$_.Name}}, Count | `
  Export-CSV DL-ACTIVE_Historical.csv –notype
4. Compare the results and output the inactive DLs
$file1 = Import-CSV -Path "DL-ALL_Present_Tense.csv"
 $file2 = Import-CSV -Path "DL-ACTIVE_Historical.csv"
 Compare-Object $file1 $file2 -syncWindow 1000 `
  -Property PrimarySmtpAddress -PassThru | `
  Where-Object{$_.SideIndicator -eq '<='} | `
  Select-Object -Property PrimarySmtpAddress | `
  Export-Csv DL-EXISTING_DLs_Inactive_last_180_days.csv -NoType
5. Compare the results and output the "non-existing" active DLs (documentation purposes only)
$file1 = Import-CSV -Path "DL-ALL_Present_Tense.csv"
 $file2 = Import-CSV -Path "DL-ACTIVE_Historical.csv"
 Compare-Object $file1 $file2 -syncWindow 1000 `
  -Property PrimarySmtpAddress -PassThru | `
  Where-Object{$_.SideIndicator -eq '=>'} | `
  Select-Object -Property PrimarySmtpAddress | `
  Export-Csv DL-NONEXISTING_DLs_Inactive_last_180_days.csv -NoType
6a. Hide all unused DLs from the Global Address List
$a = Get-Date
 $notes = "$a - Hidden from address list due to inactive use."
 $inactiveDL = Import-CSV -Path "DL-EXISTING_DLs_Inactive_for_180_days.csv"
 foreach ($DL in $inactiveDL)
   {
    Set-Group -identity $DL.PrimarySmtpAddress -notes $notes
    Set-DistributionGroup -identity $DL.PrimarySmtpAddress `
     -HiddenFromAddressListsEnabled $true
   }
6b. Delete all unused DLs from the Global Address List
$a = Get-Date
 $notes = "$a - No longer mail enabled due to inactive use."
 $inactiveDL = Import-CSV -Path "DL-EXISTING_DLs_Inactive_for_180_days.csv"
 foreach ($DL in $inactiveDL)
  {
   Set-Group -identity $_.PrimarySmtpAddress -notes $notes
   Disable-DistributionGroup -identity $_.PrimarySmtpAddress -Confirm $false
  }

MCITP: Enterprise Messaging Administrator on Exchange 2010

I set a goal this year to complete the "MCITP: Enterprise Messaging Administrator on Exchange 2010" certification.

I have completed one of the prerequisite courses (Course 10135) and have scheduled to attend the other required course in July.

Course 10135 - Configuring, Managing and Troubleshooting Microsoft Exchange Server 2010
Course 10233 - Designing and Deploying Messaging Solutions with Microsoft Exchange Server 2010 

At this point, I plan to attempt to pass Exam 70-662 and Exam 70-663 during the same time frame.

I will share, as applicable.