Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Overview of this book

Table of Contents (21 chapters)
Microsoft Exchange Server PowerShell Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
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 to find commonly-used automatic shell variables and type accelerators, along with a list 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

$$

This contains the last token in the last command received.

$?

This contains the execution status of the last command.

$^

This contains the first token in the last command received.

$_

This contains the current object being processed within a pipeline.

$Args

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

$Error

This 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

This 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

This 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

This provides a Boolean false value when used in commands and scripts.

$ForEach

This contains the enumerator inside a ForEach-Object loop.

$Home

This contains the full path to the user's home directory.

$Host

This contains an object that represents the current PowerShell host application.

$Input

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

$MaximumHistoryCount

This specifies the maximum number of entries that can be saved in the command history in the current Shell session.

$Null

This provides a null or empty value when used in commands and scripts.

$Profile

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

$PSHome

This contains the full path to the installation directory of Windows PowerShell.

$Pwd

This contains the path to the current location.

$True

This 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 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

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

AntispamCommon.ps1

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

CheckDatabaseRedundancy.ps1

This monitors the redundancy of replicated mailbox databases.

CheckInvalidRecipients.ps1

This fixes recipient objects that have multiple primary SMTP addresses defined.

CITSConstants.ps1

This file contains global constants used by CI Troubleshooter library.

CITSLibrary.ps1

This file contains the Content Index Troubleshooter functions.

CITSTypes.ps1

This file contains additional types used by CI troubleshooter library.

CollectOverMetrics.ps1

This reports on the database availability group, switchover, and failover metrics.

CollectReplicationMetrics.ps1

This reports on the replication status and statistics for databases.

ConfigureAdam.ps1

This is used to modify the default configuration of the Active Directory Application Mode (ADAM) directory service on the Edge Transport server.

ConfigureCafeResponseHeaders.ps1

This possibly modifies the OWA response header. CAFE is an abbreviation for Client Access Front End.

Configure-EnterprisePartnerApplication.ps1

This configures a Partner Application that uses the OAuth protocol to authenticate to Exchange.

ConfigureNetworkProtocolParameters.ps1

This 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 by CAS server role.

Configure-SMBIPsec.ps1

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

ConvertOABVDir.ps1

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

ConvertTo-MessageLatency.ps1

This provides end-to-end latency information gathered from message tracking logs.

DagCommonLibrary.ps1

This contains a collection of DAG-related functions for use by other scripts.

DatabaseMaintSchedule.ps1

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

DiagnosticScriptCommonLibrary.ps1

This script is a library of functions for common diagnostic script executions. Diagnostic scripts to dot source file to invoke the functions.

Disable-AntimalwareScanning.ps1

This disables anti-malware scanning.

Disable-InMemoryTracing.ps1

This is used to undo the changes made by the Enable-InMemoryTracing.ps1 script.

Disable-Outsideln.ps1

This disables Oracle Outside In Technology (c) for text extraction.

Enable-AntimalwareScanning.ps1

This enables antimalware scanning.

Enable-CrossForestConnector.ps1

This configures a send connector for cross-forest trust for anonymous users.

Enable-InMemoryTracing.ps1

This enables In Memory Tracing.

Enable-OutlookCertificateAuthentication.ps1

This configures virtual directories to allow Outlook for smart card authentication.

Enable-Outsideln.ps1

This enables Oracle Outside In Technology (c) for text extraction.

ExchUCUtil.ps1

This configures Exchange Unified Messaging for the use of Office Communications Server.

Export-MailPublicFoldersForMigration.ps1

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

Export-OutlookClassification.ps1

This generates the Classifications.xml file for Outlook.

Export-PublicFolderStatistics.ps1

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

Export-RetentionTags.ps1

This exports retention tags to an external file.

FilteringConfigurationCommands.ps1

This finds and backs up the FIPS configuration file, returns the full path to the FIPS configuration file, and returns null on failure.

get-AntispamFilteringReport.ps1

This generates a report on anti-spam filtering.

get-AntispamSCLHistogram.ps1

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

get-AntispamTopBlockedSenderDomains.ps1

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

get-AntispamTopBlockedSenderIPs.ps1

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

get-AntispamTopBlockedSenders.ps1

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

get-AntispamTopRBLProviders.ps1

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

get-AntispamTopRecipients.ps1

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

Get-PublicFolderMailboxSize.ps1

This retrieves the size of the public folder mailbox, excluding the size of deleted folders.

Get-StoreTrace.ps1

This troubleshoots Store Traces.

Get-UCPool.ps1

This reports on the UC Pools created by OCS/Lync.

GetValidEngines.ps1

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

Import-MailPublicFoldersForMigration.ps1

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

Import-RetentionTags.ps1

This imports retention tags from an external file.

Install-AntispamAgents.ps1

This installs the anti-spam agents on a mailbox server.

MailboxDatabaseReseedUsingSpares.ps1

This validates the safety of the environment, before swapping fails to copy database to a spare disk and reseeding.

ManagedStoreDiagnosticFunctions.ps1

This runs a query against a managed store mailbox database.

ManageScheduledTask.ps1

This manages scheduled tasks in PowerShell.

Merge-PublicFolderMailbox.ps1

This merges the contents of the given public folder mailbox with the target public folder mailbox.

MigrateUMCustomPrompts.ps1

This migrates a copy of all Unified Messaging custom prompts.

MoveMailbox.ps1

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

Move-PublicFolderBranch.ps1

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

Move-TransportDatabase.ps1

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

new-TestCasConnectivityUser.ps1

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

Prepare-MoveRequest.ps1

This prepares mailboxes for cross-forest mailbox moves.

PublicFolderToMailboxMapGenerator.ps1

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

RedistributeActiveDatabases.ps1

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

ReinstallDefaultTransportAgents.ps1

This reinstalls default transport agents on servers.

RemoveUserFromPFRecursive.ps1

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

ReplaceUserPermissionOnPFRecursive.ps1

This 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

This 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

This removes the anti-spam agents from a transport server.

ResetAttachmentFilterEntry.ps1

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

ResetCasService.ps1

This resets the virtual directory on CAS.

ResumeMailboxDatabaseCopy.ps1

This resumes activation and log file replication for specified mailbox databases.

RollAlternateServiceAccountPassword.ps1

This is used to update the service account credentials and distributes the update to specified CAS servers.

SearchDiagnosticInfo.ps1

This prints the result of Get-SearchDiagnosticInfo.

Split-PublicFolderMailbox.ps1

This splits the given public folder mailbox based on the size of the folders.

StartDagServerMaintenance.ps1

This initiates the DAG server maintenance.

StopDagServerMaintenance.ps1

This stops the DAG server maintenance and resumes mailbox database copies.

StoreTSConstants.ps1

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

StoreTSLibrary.ps1

This is a collection of Store Troubleshooting on Content Index (CI) catalogs.

Troubleshoot-CI.ps1

This performs troubleshooting on Content Index catalogs.

Troubleshoot-DatabaseLatency.ps1

This diagnoses disk subsystem issues (used by SCOM).

Troubleshoot-DatabaseSpace.ps1

This troubleshoots log growth (used by SCOM).

Uninstall-AntispamAgents.ps1

This uninstalls the anti-spam agents.

Update-AppPoolManagedFrameworkVersion.ps1

This is used during the installation and updates the procedure for updating the Application Pool.

Update-MalwareFilteringServer.ps1

This 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.