Pro-Exchange,Lync & Office 365
Belgian Microsoft Unified Communications Professionals
Microsoft Exchange Server, Microsoft Lync Server & Office 365
The Exchange 2010 Scripts


Both Exchange 2007 and Exchange 2010 are accompanied by a bunch of pre-created scripts that allow you to perform various tasks ranging from configuring some extra services to some basic reporting. These scripts reside in a “scripts”-folder within the Exchange installation folder and can easily be reached using the “$exscripts”-variable (which contains the path to the folder) from the Exchange Management Shell:


Almost every Service Pack that was released introduced some new scripts. Because Exchange 2010 SP2 recently hit the road, I decided to create an overview of the new scripts that shipped with it along with the existing ones. In the overview I will try to gather the available information and explain the script’s purpose. I will also try to keep this list up to date if newer scripts would be released in the future.

Did you know?

The TechNet website offers a lot of scripts with various purposes that can be used with different versions of Exchange. The repository contains scripts from both the MS Exchange Team as other Exchange professionals and are freely available for download. Check out the TechNet Script Repository for more fancy scripts!

The “stars” of the scripts folder

The following list contains all scripts from the Exchange 2010 Scripts folder with information I gathered from various resources (mostly TechNet) as well as personal experiences. Sources and additional information are always mentioned under “More information:”




This script will add replicas to existing Public Folders and is often used during migrations from one Exchange version to another (e.g. Exchange 2003 to Exchange 2010).

To execute the script, use the following syntax:

  • AddReplicaToPFRecursive.ps1 –Server <oldservername> –ServerToAdd <newservername> –TopPublicFolder <pfname>


This script will add user permissions to Public Folders.

Note: If you use the script, but a user has already access to a specific Public Folder, the script will throw a warning.
More information:


The script aggregates and captures information collected from three cmdlets:

  • Get-PublicFolderItemStatistics
  • Get-PublicFolderStatistics
  • Get-PublicFolder

The following information is aggregated at the public folder level, and not at the item level:

  • Last user access and last user modification times
  • Owner of the public folder
  • Properties such as MailEnabled, HasRules, ItemCount, FolderType, HasModerator, and TotalItemSize
More information:


This script is referenced by other anti-spam scripts in Exchange 2007 and is not intended to be used directly.


Checks the redundancy of databases by validating that they have at least N configured and "healthy" copies. Active and passive copies are both counted.

To use this script you need to provide either $MailboxDatabaseName or $MailboxServerName.To generate events for Monitoring, you need to provide -MonitoringContext switch.

Note: This scripts will only provide an output if a DAG is present in the environment.


This script is designed to return information on invalid recipient objects and possible attempt to fix them.

The script will attempt to fix two classes of errors:

  • Primary SMTP Address Problems:    If a recipient has multiple SMTP addresses listed as primary or the primary SMTP is invalid, the script will try to set the WindowsEmailAddress as the primary SMTP address, since that is the address Exchange 2003 would have recognized as the primary (although E12 does not)
  • Distribution Group Hidden Membership:    If a distribution group has HideDLMembershipEnabled set to true, but ReportToManagerEnabled, ReportToOriginatorEnabled and/or SendOofMessageToOriginatorEnabled are set to true, then the membership is not actually securely hidden. The script will set ReportToManagerEnabled, ReportToOriginatorEnabled and SendOofMessageToOriginatorEnabled to false to fix the distribution group.

Note: to automatically try fixing reported problems, the –FixErrors switch needs to be provided.


This file contains global constants used by CI Troubleshooter library


This file contains Content Index Troubleshooter functions


This file contains additional types used by CI troubleshooter library


This script reads DAG member event logs to gather information about database operations (such as database mounts, moves, and failovers) over a specific time period. For each operation, the script records the following information:

  • Identity of the database
  • Time at which the operation began and ended
  • Servers on which the database was mounted at the start and finish of the operation
  • Reason for the operation
  • If the operation was successful, including the error details if the operation failed

The script writes this information to .csv files with one operation per row. It writes a separate .csv file for each DAG.

More information:


This script provides an active form of monitoring because it collects metrics in real time, while the script is running. It collects data from performance counters related to database replication. The script gathers counter data from multiple Mailbox servers, writes each server's data to a .csv file, and can then report various statistics across all of this data (for example, the amount of time each copy was failed or suspended, the average copy or replay queue length, or the amount of time that copies were outside of their failover criteria).

More information:


This script is to be used to help add the necessary IPsec configuration to protect SMB (File Share) communication.


You can use the ConfigureAdam.ps1 script in the Shell to modify the default configuration of the Active Directory Lightweight Directory Services (AD LDS) on the Edge Transport server.

After you install the Edge Transport server role, you can use the ConfigureAdam.ps1 script provided with Exchange 2010 to modify the ports and directories that AD LDS uses. The ConfigureAdam.ps1 script invokes the dsdbutil command to change the registry settings for AD LDS.


Configures a Global Catalog running on the machine on which the script is run to listen on the standard NSPI Rpc-over-Http port 6004. This would enable Rpc-over-Http connections from Outlook clients to a GC, RpcProxy'ed by CAS boxes.

More information:


This script will convert the OAB virtual directory to an IIS web application, as well as, create a new application pool, MSExchangeOabAppPool. Converting the OAB virtual directory is necessary to support different authentication methods like Kerberos and Certificate authentication.

Note: You need to execute this script on each Client Access Server.
More Information:


This script enables you to get latency information any email still in the Message Tracking Logs. This can be useful in troubleshooting scenarios where you have to deal e.g. with slow email delivery.


A collection of DAG-related functions for use by other scripts.


Random generates maintenance and quota notification schedule time based on the specified criteria.


Library file used by scripts in the Management Pack for Exchange 2010 (SCOM)


This script will undo the changes made by the Enable-InMemoryTracing.ps1 script.

  • .\Disable-InMemoryTracing.ps1


When you want to establish direct mail flow with servers that are running Exchange in a different Active Directory forest, you must configure both Send- and Receive connector with.

This script will adjust the permissions on a Send Connector (add ‘ANONYMOUS LOGON’ to the Send Connector)

More information:


This script will enable In-Memory tracing by changing the InMemoryTracing value from $false to $true in the EnabledInMemoryTraces.config in the bin directory, found under the the Exchange Install Folder.

  • .\Enable-InMemoryTracing.ps1


This script will configure the different virtual directories so that Outlook can used Smart Card Authentication.

More information:


Script that makes necessary changes so that OCS/Lync can read UM data from Exchange.

More information:


Script that exports your message classifications so that they can be imported into Outlook. The script will generate an XML-file.

More information:


This script is used in conjunction with the Import-RetentionTags.ps1 script and exports existing Retention Policy Tags to an xml file. It has proven to be useful in deployments where also Exchange Online (Office 365) is used. 
If a user applied Retention Policy Tags prior to moving his mailbox to the cloud, they need to be exported from the on-premise environment and imported to Office 365. This has to be done prior to moving the mailbox. 

Running the script is relatively easy:
  • .\Export-RetentionTags.ps1 <path_to_xml_file>
More information:


You can run this script to draw a report for the Exchange Anti Spam Agents. The following values are accepted as command parameters:
  • messagesrejected
  • messagesdeleted
  • connections
  • messagesquarantined


  • .\Get-AntispamFilteringReport.ps1 <command> –report <path>


This script will output the total number of emails calculated for every SCL Rating.

  • .\Get-AntispamSCLHistogram.ps1

More information:


This script will show you which domains have the largest share in the amount of spam sent to you.

Note: this information can sometimes be misleading because spammers tend to spoof real email addresses. This script cannot and does not take this into account. However, for domains that you are absolutely sure you don’t want to get emails from, this might prove very useful.


This script will show the top 10 IP addresses that have sent you spam. This can be useful for building up a list of IP’s to blacklist.


This script will provide the top 10 of email addresses that have sent you spam.


This script can be used for “monitoring” the RBL provides that are configured for your environment. It will provide you an overview of the configured RBL’s and the amount of “hits” they have provided you with.


This script will provide you with an overview of the email addresses within your organization that are prone to receiving spam.


This script will “parse” the Exchangesetup.log and show it on screen in a more readable way.


This script will query Active Directory and report back on any UC Pools that might have been configured for OCS/Lync


This script will return the database that is associated with a set of catalog files.

To use the script, run a Get-Childitem of the directory containing the catalog files and pipe it through to the script.

  • Get-ChildItem <path> | GetDatabaseForSearchIndex.ps1


This script does exactly the opposite of the GetDatabaseforSearchIndex.ps1 script. It will provide you the path to the catalog files for the database you provided with the script.

Note: to use this script add the database name after the script. E.g.: GetSearchIndexForDatabase.ps1 “Mailbox Database”


This script will import Retention Tags that have previously been exported with the Export-Retentiontags.ps1 script.


This script will install and enable the following Anti-Spam agents on a Hub Transport Server:
  • Connection filtering
  • Content filtering
  • Sender ID
  • Sender filtering
  • Recipient filtering
  • Sender reputation

Note: after running the script the Microsoft Exchange Transport services needs to be restarted.
For more information:


This script was released with Exchange 2010 SP1 RU4 in order to solve the following issue:

Note: This script requires PowerShell v2. It uses Remote Registry Service & WS-Management on E2K10 CAS Servers. 


This script was also released with Exchange 2010 SP1 RU4 in order to solve the following issue:

The script will change the value for the MaxTokenSize registry key.

More information: &


This script is used for reference only. Executing the script will fail as a referenced library is missing. This library is actually used within Microsoft but is not available for the public.

Note: A big thanks to Tonino for helping me out with this one.


This script allows to add/modify/remove scheduled tasks through PowerShell.

The following parameters are accepted:
  • Install
  • DeleteExisting
  • ServerName
  • TaskName
  • PsScriptPath
  • PsScriptArgs
  • Uninstall
  • Disabled
  • Enable
  • TestExistence
  • RunFromSetup

  • Usage:
    To create a new scheduled task that will run a custom script called “custom.ps1”, run the following cmdlet:
    • ManageScheduledTask.ps1 –Install –ServerName <servername> –PsScriptPath .\custom.ps1 –TaskName “Custom Script”


    This script is used to migrate a copy of the UM custom prompts in Exchange 2007 (UM) to Exchange 2010 (UM). Custom prompts are audio files used in the Exchange UM Role that contain customized welcome-messages and –announcements.

    More information:


    This script will move the Transport Database (mail.que) and log files to a new location. Next to moving the files, the script takes also care of stopping/starting the necessary services and it will create the target folder (including permissions) if it does not exist yet.

    • Move-TransportDatabase –queueDatabasePath <path> –queueDatabaseLoggingPath <path>


    When you are migrating Public Folders (e.g. when transitioning from Exchange 2003 to Exchange 2007 or 2010) all replicas must be moved off the legacy environment before you can decommission it.

    Although you could perform this action manually as well, the script will allow you to easily perform the action of moving all existing replicas to the (new) server that you define.

    • Moveallreplicas.ps1 –server<sourceserver> -newserver<destinationserver>


    By default, Exchange 2010 performs mailbox moves asynchronously. However; in some cases an Administrator might require moves to be executed synchronously. In that case ,this script can be used.

    The script accepts pretty much the same parameters used with the New-MoveRequest cmdlet
    • .\MoveMailbox.ps1 –Identity <id> –TargetDatabase <targetdb>
    More information:


    In order to use some of the end-to-end diagnostic cmdlet in Exchange 2010, you need to create a test-user that can be used to execute the cmdlets.

    A good example where this is needed, if when you deploy System Center Operations Manager. The cmdlets executed by SCOM to check the Exchange’s health require, the test user to be present.

    • .\New-TestCasConnectivityUser.ps1 
    More information:


    Before you can run the New-MoveRequest to move mailboxes across forests, a mail use needs to exist in the target forest. This script will create a mail user in the target forest (based on the user in the source forest) and will also copy the AD attributes from the source object to the target object.

    More information:


    A Database Availability Group is an active environment in which database can (and will) be moved from one mailbox server to another for various reasons:
    • Maintenance
    • Failure
    • Corruption

    Over time, databases could be active on servers other than the ones that you had foreseen initially. This script will allow you to “rebalance” your active databases on servers participating in your DAG, based on the db’s activation preference.

    More information:


    When upgrading to Exchange 2010 SP1, in Exchange 2010 RTM, running “ /prepareAD” the Admin Audit Log Agent gets disabled. It will not be running until the installation is completed. Run this script to fix this issue. The script will roll back the msExchangeVersion of the Agent.

    Note: the issue goes away automatically once SP1 is completely installed.


    • .\Reenable-AuditLoggingAgent.ps1


    This script will reinstall the default Transport Agents for a Hub Transport or Edge Server. It can for instance be used to recover from an issue with transport agents.

    • .\ReinstallDefaultTransportAgents.ps1

    Note: the MS Exchange Transport services needs to be restarted after running this cmdlet.


    The script will remove a server from the replication list of a Public Folder and it’s subfolders. If the server isn’t listed, nothing is changed as well as when the server holds the only replica.

    More information:


    This script removes a user from the client permissions list for a public folder and from all the folders beneath it in the hierarchy.

    More information:


    This script will replace a server listed as a replica by a new server for all public folders and the folders beneath it in the hierarchy. If the server to replace isn’t listed, nothing will be changed for that particular folder.

    More information:


    This script replace permissions of a user in the permission list for a public folder and the folders beneath it in the hierarchy with new permissions. If no permissions for the user can be found, nothing will be changed on that particular folder.

    More information:


    This script replaces a user with another user in the permissions list for a public folder or the folders beneath it in the hierarchy. If no permission entries can be found, nothing will be changed. Note that existing permissions will not be removed.

    More information:


    This script resets baseline antispam data to original out-of-box state

    • .\Reset-AntiSpamUpdates.ps1


    This script is used to reset the list of attachment-types that are blocked by the attachment-filtering feature, to the factory set defaults. It will do this by first removing the existing entries and then adding the default ones. If needed additional filenames or extensions can be added to the script.


    • ResetAttachmentFilterEntry.ps1


    This script will reset and recreate the virtual directory for the service that you define.

    • .\ResetCasService.ps1 <service> “<identity>”

    for example:

    • .\ResetCasServices.ps1 owavirtualdirectory “owa (default web site)”


    This script will remove the Search Index Catalog associated with the specified Mailbox Database.

    • .\ResetSearchIndex.ps1 <databasename>

    Note: optionally the –force parameter can be passed to the script as well. If –force is used, the script will not prompt for confirmation when deleting the Catalog directory.


    This script will resume activation and log file replication (copy and replay) for the specified mailbox database.

    The script accepts the following parameters:
    • Datacenter
    • MailboxServer
    • Database
    • .\ResumeMailboxDatabaseCopy.ps1 –database <dbname>


    In a setup where Kerberos Authentication is used for MAPI client connectivity, a so-called Alternative Service Account (ASA) is used. You can use this script to generate a new password for the service account and propagate it to the Client Access Servers.

    More information:


    Whenever you need to do some patching on a server that is part of a DAG, there are some actions that you need to take to make sure that the node you are working on is temporarily disregarded by the DAG:

    • Move active databases to another DAG member
    • Pause the node in the cluster
    • Block the Database Copy Auto Activation on the mailbox server
    • Block replication and replay activities for each database hosted by the server
    • Optionally move cluster core resources to another server in the DAG

    Instead of manually performing the tasks above, the StartDagServerMaintenance.ps1 script will perform all of the steps automatically.

    The script is used together with the –Servername parameter which defines what server to put in ‘maintenance mode’.


    • StartDagServerMaintenance.ps1 –ServerName <servername>
    More information:


    This script will reverse the action performed by the StartDagServerMaintenance.ps1 script.

    More specifically, it will perform the following actions:

    • Run the Resume-MailboxDatabaseCopy cmdlet for each database copy hosted by the server
    • Resume the node in the cluster
    • Re-enable Database Copy Auto Activation (sets the DatabaseCopyAutoActivationPolicy to Unrestricted)

    This script is also run with the –Servername parameter.


    • StopDagServerMaintenance.ps1 –ServerName <servername>

    More information:


    This file/script stores the default settings used by the Troubleshoot-DatabaseLatency.ps1 script.

    More information:


    A collection of Store Troubleshooter functions for use by other scripts like:
    • Troubleshoot-DatabaseLatency.ps1
    • Troubleshoot-DatabaseSpace.ps1


    This script monitors (and performs) troubleshooting on the Content Index catalogs. It detects and resolves the following issues:
    • Deadlocks
    • Corruption
    • Stalls
    • Backlog

    This troubleshooter can be used against the server or just a database, and can be used to detect as well as resolve problems. It can also be used in just a monitoring context to log warnings and failure events in the app log.

    For an usage example, check out on of my earlier blog posts:

    More information:


    This script is used by System Center Operations Manager (SCOM) to detect (and correct) latency issues on a database. Alternatively you can also create a scheduled task to run this script at predefined times.

    The scripts executes the following tasks:
    • Checks whether database latencies are above the latency threshold of 70ms.
    • Checks whether the disk's transfers-per-second rate is less than the DiskReadRateThreshold performance counter and whether the disk's seconds-per-transfer rate is greater than the DiskReadLatencyThreshold performance counter. If this is the case, the script determines that the disk must be replaced because it's under low-load conditions but is exhibiting high latencies.
    • Checks whether a single user is using more than one thread over the last 10 minute period for longer than the value specified by the TimeInServerThreshold parameter. If this is the case, the user is likely contributing to the high latencies, and, as a result, the user's mailbox is quarantined. The user's mailbox is quarantined for six hours, during which the user won't have access to e-mail.

    More information:


    Just as the Troubleshoot-DatabaseLatency.ps1-script, this script is used by SCOM 2007 to detect and correct any abnormal growth of either log files or database file (.edb). Alternatively, you can schedule a task to execute this script at predefined intervals.

    The script executes the following tasks:
    • Keeps track of log generation rate for the highest log generators per database.
    • Keeps track of the available disk space for both the database and the log files.
    • Keeps track of the log generation rate. If it appears that the disk is going to run out of space within the value specified by the HourThreshold parameter (based on the log generation rate), further action must be taken.
    • If all of the preceding conditions are fulfilled, the script determines the list of top 25 users who accessed the database during the last one-hour period. The script then quarantines the top high-usage mailboxes for which the sum of the log generation rate is greater than the difference between the current generation rate and the sustainable generation rate that would allow tiding over the configurable time threshold. These users are quarantined for six hours, during which they won't have access to e-mail.
    • If the troubleshooter is unsuccessful at dropping the log generation rate to below the threshold level, it will write out events that translate into health model alerts. At this point, the script removes the database from provisioning by running the Set-MailboxDatabase cmdlet with the ExcludeFromProvisioning parameter set to $true against the specified database. You may need to move mailboxes to a new server to rebalance space.
    • If the troubleshooter quarantines more than 10 users, this indicates a systemic issue, which you need to follow up on. The health model will trigger an urgent alert from this condition.

    More information:


    This script will reverse the actions performed by the Install-AntiSpamAgents.ps1 script and uninstall the Exchange Anti Spam Agents from the Hub Transport Server.

    Note: the Microsoft Exchange Transport Service needs to be restarted after running this script. To verify that the transport agents have been uninstalled successfully, you can run the Get-TransportAgent cmdlet. Otherwise, you can also make sure that the Anti-spam tab is removed from the Exchange Management Console.

    Posted 12-18-2011 9:58 by Michael Van Horenbeeck

    Comments wrote
    on 09-13-2014 12:36

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365 wrote
    on 09-20-2014 12:31

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365

    Globlins Hack wrote Globlins Hack
    on 09-22-2014 1:37

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365

    hay day triche code hack tool wrote hay day triche code hack tool
    on 09-24-2014 7:56

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365 wrote
    on 09-28-2014 2:00

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365 wrote
    on 09-30-2014 2:50

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365

    saints row 4 cheats wrote saints row 4 cheats
    on 10-08-2014 3:59

    The Exchange 2010 Scripts - Exchange 2010 - Pro-Exchange,Lync & Office 365