Topic Last Modified: 2013-03-07

Replaces one or more Persistent Chat messages in the Persistent Chat database with a default message or with an administrator-provided message. This cmdlet was introduced in Lync Server 2013.


Remove-CsPersistentChatMessage -ReplaceMessage <String> [-CaseSensitive <$true | $false>] [-EndDate <DateTime>] [-Filter <String>] [-MatchClause <And | Or | Exact>] [-StartDate <DateTime>] [-UserUri <String>] <COMMON PARAMETERS>
Remove-CsPersistentChatMessage -Remove <SwitchParameter> [-CaseSensitive <$true | $false>] [-EndDate <DateTime>] [-Filter <String>] [-MatchClause <And | Or | Exact>] [-StartDate <DateTime>] [-UserUri <String>] <COMMON PARAMETERS>
Remove-CsPersistentChatMessage [-CaseSensitive <$true | $false>] [-EndDate <DateTime>] [-Filter <String>] [-MatchClause <And | Or | Exact>] [-StartDate <DateTime>] [-UserUri <String>] <COMMON PARAMETERS>
COMMON PARAMETERS: -Identity <String> [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]]


Example 1

The command shown in Example 1 removes all the Persistent Chat messages posted on or before April 1, 2012 from the ITChatRoom chat room on the server

Copy Code
Remove-CsPersistentChatMessage -Identity "\ITChatRoom" -EndDate "4/1/2012"

Example 2

In Example 2, all Persistent Chat messages posted by the user are removed from the ITChatRoom chat room on the server

Copy Code
Remove-CsPersistentChatMessage -Identity "\ITChatRoom" -UserUri ""

Detailed Description

The Persistent Chat service (which replaces the Group Chat service used in Microsoft Lync Server 2010) provides organizations with messaging and collaboration capabilities similar to those found in Internet discussion forums: users can exchange messages in real-time, yet can also revisit and restart those conversations at any time. Conversations can be based around specific topics, and these conversations can be made available to everyone or to only a selected set of users. Likewise, individual chat rooms can be configured so that anyone can post a message or configured so that only designated presenters can post messages.

Persistent Chat discussions take the form of messages posted in individual chat rooms; chat rooms are discussion forums based on specific topics. By design, messages posted in a chat room remain there forever; at any time, users can return to the room and review all the messages that have been previously posted.

However, there might be times when administrators need to remove messages from a chat room; for example, perhaps a user posted a series of messages with erroneous information regarding the forthcoming company meeting. The Remove-CsPersisentChatMessage cmdlet enables administrators to remove a single chat message, or to remove an entire set of chat messages based on criteria such as the user who posted the message or keywords found in that message.

To return a list of all the role-based access control (RBAC) roles this cmdlet has been assigned to (including any custom RBAC roles you have created yourself), run the following command from the Windows PowerShell command-line interface prompt:

Get-CsAdminRole | Where-Object {$_.Cmdlets –match "Remove-CsPersistentChatMessage"}

Lync Server Control Panel: The functions carried out by the Remove-CsPersistentChatMessage cmdlet are not available in the Lync Server Control Panel.


Parameter Required Type Description




Unique identifier for the chat room containing the message to be deleted. For example:

-Identity "\ITChatRoom"




When present, removes the Persistent Chat message without leaving a replacement message.

You cannot use both the Remove parameter and the ReplaceMessage parameter in the same command.




Enables administrators to specify the text of the replacement message. By default, the replacement message reads "This message was replaced by the Persistent Chat administrator."




When present, indicates that case sensitivity should be used when searching for messages to be removed. (In other words, an uppercase "A" will be treated as a different character than a lowercase "a".) By default, searches are not case sensitive.




Prompts you for confirmation before executing the command.




Enables you to filter for messages that were posted on or before the specified date.




Keywords that can be used to help identify the messages to be deleted. For example, to search for all messages that include the keyword "Fabrikam" use this syntax:

-Filter "Fabrikam"

To search for multiple keywords, put all the keywords in a single string, separated by using blank spaces:

-Filter "Fabrikam Contoso TailspinToys"

By default, the Remove-CsPersistentChatMessage cmdlet will look for messages using all the specified keywords. To look for messages using any one of the provided keywords, use the MatchClause parameter and set the parameter value to "Or".




Specifies how the Remove-CsPersistentChatMessage cmdlet handles multiple keywords. Allowed values are:

* All (A message must include all the specified keywords in order to be a match)

* Or (A message containing one or more of the specified keywords will be considered a match)

* Exact (Messages must exactly match the specified phrase, including the word order, in order to be a match)

For example, this syntax searches for messages that have the exact phrase "For internal use only) in the message text:

-Filter "For internal use only" –MatchClause "Exact"




Enables you to filter for messages that were posted on or after the specified date.




SIP address of the user who posted the message (or messages) that should be removed.




Describes what would happen if you executed the command without actually executing the command.

Input Types

None. The Remove-CsPersistentChatMessage cmdlet does not accept pipelined input.

Return Types


See Also