Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Exchange Server 2013 PowerShell Cookbook: Second Edition

You're reading from   Microsoft Exchange Server 2013 PowerShell Cookbook: Second Edition Benefit from over 120 recipes that tackle the everyday issues that arise with Microsoft Exchange Server. Using PowerShell you'll learn to add scripts that provide new functions and efficiencies. Only basic knowledge required.

Arrow left icon
Product type Paperback
Published in May 2013
Publisher Packt
ISBN-13 9781849689427
Length 504 pages
Edition 2nd Edition
Concepts
Arrow right icon
Toc

Table of Contents (23) Chapters Close

Microsoft Exchange Server 2013 PowerShell Cookbook
Credits
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. PowerShell Key Concepts FREE CHAPTER 2. Exchange Management Shell Common Tasks 3. Managing Recipients 4. Managing Mailboxes 5. Distribution Groups and Address Lists 6. Mailbox Database Management 7. Managing Client Access 8. Managing Transport Service 9. High Availability 10. Exchange Security 11. Compliance and Audit Logging 12. Server Monitoring and Troubleshooting 13. Scripting with the Exchange Web Services Managed API Common Shell Information Query Syntaxes Index

Exchange Management Shell reference


This appendix provides additional information related to the Exchange Management Shell (EMS). You can use this section as a reference for finding commonly-used automatic shell variables and type accelerators, along with a listing of commonly-used EMS scripts that are installed with Exchange 2013. Additionally, common filterable properties supported by EMS cmdlets that include filter parameters are outlined in detail.

Commonly-used shell variables

PowerShell and the Exchange Management Shell provide several automatic variables. The following table provides a list of commonly-used automatic variables with a description for each one:

Variable Name

Description

$$

Contains the last token in the last command received.

$?

Contains the execution status of the last command.

$^

Contains the first token in the last command received.

$_

Contains the current object being processed within a pipeline.

$Args

Contains an array of undeclared arguments received by a function, script, or script block.

$Error

Contains an array of error objects recorded in the current shell session. The latest error can be accessed using the zero index of the array, that is, $error[0].

$Exbin

References the full path to the Exchange Server\Bin directory. This variable is only present when starting the shell using the Exchange Management Shell shortcut on a machine with the Exchange tools installed.

ExScripts

References the full path to the Exchange scripts directory. This variable is only present when starting the shell using the Exchange Management Shell shortcut on a machine with the Exchange tools installed.

False

Provides a Boolean false value when used in commands and scripts.

$ForEach

Contains the enumerator inside a ForEach-Object loop.

$Home

Contains the full path to the user's home directory.

$Host

Contains an object that represents the current PowerShell host application.

$Input

Contains the enumerator for items passed to a function. The $Input variable can access the current object being processed within a pipeline.

$MaximumHistoryCount

Specifies the maximum number of entries that can be saved in the command history in the current shell session.

$Null

Provides a NULL or empty value when used in commands and scripts.

$Profile

Contains the full path to the PowerShell profile for the current user and the current host application.

$PSHome

Contains the full path to the installation directory of Windows PowerShell.

$Pwd

Contains the path to the current location.

$True

Provides a Boolean true value.

To view the variables currently defined in your shell session, run Get-Variable. You can also read more about PowerShell variables by running the Get-Help <TopicName> cmdlet on the following about topics:

  • about_Automatic_Variables

  • about_Environment_Variables

  • about_Preference_Variables

Note

The preceding topics only reference PowerShell-specific variables, and not the shell variables that are specific to the Exchange Management Shell.

Commonly-used type accelerators

Type accelerators, also referred to as type shortcuts, allow you to create an object of a specific .NET Framework type without having to enter the entire type name. This is a feature that is supported by both PowerShell and the Exchange Management Shell, and allows you to reduce the amount of typing required when creating an object or explicitly typing a variable. The following table lists some of the most commonly-used type shortcuts:

Type shortcut

.NET framework type

[int]

System.Int32

[long]

System.Int64

[string]

System.String

[bool]

System.Boolean

[byte]

System.Byte

[double]

System.Double

[decimal]

System.Decimal

[datetime]

System.DateTime

[array]

System.Array

[hashtable]

System.Collections.HashTable

[switch]

System.Management.Automation.SwitchParameter

[adsi]

System.DirectoryServices.DirectoryEntry

Scripts available in the $Exscripts directory

The following table lists some of the most commonly-used EMS PowerShell scripts that are installed with Exchange 2013:

Name

Description

AddUsersToPFRecursive.ps1

Adds a user and their permissions to the client permissions list for a public folder and all the folders beneath it in the hierarchy.

CheckDatabaseRedundancy.ps1

Monitors the redundancy of replicated mailbox databases.

CheckInvalidRecipients.ps1

Fixes recipient objects that have multiple primary SMTP addresses defined.

CollectOverMetrics.ps1

Reports on the database availability group, switchover, and failover metrics.

CollectReplicationMetrics.ps1

Reports on the replication status and statistics for databases.

ConvertOABVDir.ps1

Converts the OAB virtual directory to an IIS web application/application pool.

ConvertTo-MessageLatency.ps1

Provides end-to-end latency information gathered from message tracking logs.

DatabaseMaintSchedule.ps1

Generates the maintenance and quota notification schedule time based on a set of input values.

Disable-AntimalwareScanning.ps1

Disables Antimalware scanning.

Disable-InMemoryTracing.ps1

Used to undo the changes made by the Enable-InMemoryTracing.ps1 script.

Enable-AntimalwareScanning.ps1

Enables Antimalware scanning.

Enable-CrossForestConnector.ps1

Configures a send connector for cross-forest trust for anonymous users.

Enable-InMemoryTracing.ps1

Enables In Memory Tracing.

ExchUCUtil.ps1

Configures Exchange Unified Messaging for the use of Office Communications Server.

Export-MailPublicFoldersForMigration.ps1

Exports the properties of all the mail-enabled public folders to a CSV file.

Export-PublicFolderStatistics.ps1

Generates a CSV file with lists of public folders and the individual sizes.

Export-RetentionTags.ps1

Exports retention tags to an external file.

get-AntispamFilteringReport.ps1

Generates a report on anti-spam filtering.

get-AntispamSCLHistogram.ps1

Reports on all entries for the Content Filter and groups by SCL values.

get-AntispamTopBlockedSenderDomains.ps1

Reports on the top 10 (unless specified otherwise) sender domains blocked by anti-spam agents.

get-AntispamTopBlockedSenderIPs.ps1

Reports on the top 10 (unless specified otherwise) sender IPs blocked by anti-spam agents.

get-AntispamTopBlockedSenders.ps1

Reports on the top 10 (unless specified otherwise) senders blocked by anti-spam agents.

get-AntispamTopRBLProviders.ps1

Reports on the top 10 (unless specified otherwise) reasons for rejection by blocklist providers.

get-AntispamTopRecipients.ps1

Reports on the top 10 (unless specified otherwise) recipients rejected by anti-spam agents.

Get-UCPool.ps1

Reports on the UC Pools created by OCS/Lync.

GetValidEngines.ps1

Returns a list of engines being used by the forefront filtering agent.

Import-MailPublicFoldersForMigration.ps1

Imports the mail-enabled public folders from a CSV file and calls the cmdlet Enable-MailPublicFolder.

Import-RetentionTags.ps1

Imports retention tags from an external file.

Install-AntispamAgents.ps1

Installs the anti-spam agents on a mailbox server.

MailboxDatabaseReseedUsingSpares.ps1

Validates the safety of the environment, before swapping failed database copy to a spare disk and reseeding.

ManageScheduledTask.ps1

Manages scheduled tasks in PowerShell.

Merge-PublicFolderMailbox.ps1

Merges the contents of the given public folder mailbox with the target public folder mailbox.

MigrateUMCustomPrompts.ps1

Migrates a copy of all Unified Messaging custom prompts.

Move-PublicFolderBranch.ps1

Moves the contents of folders that reside along with the given folder to the target public folder mailbox.

Move-TransportDatabase.ps1

Moves the queue database to an alternate disk on a transport server.

MoveMailbox.ps1

Works like the Move-Mailbox cmdlet in Exchange 2007 and performs synchronous mailbox moves.

new-TestCasConnectivityUser.ps1

Creates a test user that can be used when testing connectivity on CAS servers.

Prepare-MoveRequest.ps1

Prepares mailboxes for cross-forest mailbox moves.

PublicFolderToMailboxMapGenerator.ps1

Generates a CSV mapping file that contains the public folder to the mailbox structure.

RedistributeActiveDatabases.ps1

Attempts to redistribute active databases evenly across a number of mailbox servers within a DAG.

ReinstallDefaultTransportAgents.ps1

Reinstalls default transport agents on servers.

RemoveUserFromPFRecursive.ps1

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

ReplaceUserPermissionOnPFRecursive.ps1

Replaces the permissions of a user for a public folder with a new set of permissions and applies it to all the folders beneath it in the hierarchy.

ReplaceUserWithUserOnPFRecursive.ps1

Replaces a user for a new user on the client permissions list for a public folder and applies it to all the folders beneath it in the hierarchy.

Reset-AntispamUpdates.ps1

Removes the anti-spam agents from a transport server.

ResetAttachmentFilterEntry.ps1

Resets the list of attachment types for attachment-filtering to factory set defaults.

ResetCasService.ps1

Resets the virtual directory on CAS.

ResumeMailboxDatabaseCopy.ps1

Resumes activation and logfile replication for specified mailbox databases.

RollAlternateServiceAccountPassword.ps1

Updates the service account credentials and distributes the update to specified CAS servers.

SearchDiagnosticInfo.ps1

Prints the result of Get-SearchDiagnosticInfo.

Split-PublicFolderMailbox.ps1

Splits the given public folder mailbox based on the size of the folders.

StartDagServerMaintenance.ps1

Initiates DAG server maintenance.

StopDagServerMaintenance.ps1

Stops DAG server maintenance and resumes mailbox database copies.

StoreTSConstants.ps1

This file contains global constants used by the Store Database Troubleshooters.

StoreTSLibrary.ps1

A collection of Store Troubleshooting on Content Index (CI) catalogs.

Troubleshoot-CI.ps1

Performs troubleshooting on CI catalogs.

Troubleshoot-DatabaseLatency.ps1

Diagnoses disk subsystem issues (used by SCOM).

Troubleshoot-DatabaseSpace.ps1

Troubleshoots log growth (used by SCOM).

Uninstall-AntispamAgents.ps1

Uninstalls the anti-spam agents.

Update-MalwareFilteringServer.ps1

Updates the malware filter definitions.

Scripts may be added to this directory as you install rollup updates and service packs, and some of them will only be present when a specific server role is installed. For example, the anti-spam scripts will only be available on mailbox servers. To view all the scripts in the $ExScripts folder, run Get-ChildItem $exscripts –Filter *.ps1.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image