Topic Last Modified: 2013-02-22

Enables or disables one or more Lync Server user databases. This cmdlet was introduced in Lync Server 2010.


Set-CsUserDatabaseState -RegistrarPool <Fqdn> <COMMON PARAMETERS>
Set-CsUserDatabaseState -Identity <String> <COMMON PARAMETERS>
COMMON PARAMETERS: -Online <$true | $false> [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchParameter>]]



The command shown in Example 1 takes the user database offline. This is done by setting the Online property to $False.

Copy Code
Set-CsUserDatabaseState -Identity "" -Online $False


In Example 2, all the user databases on the Registrar pool are taken offline.

Copy Code
Set-CsUserDatabaseState -RegistrarPool -Online $False


Example 3 locates all the user databases that are currently offline and then brings them back online. To do this, the command first calls the Get-CsUserDatabaseState cmdlet without any parameters in order to return a collection of all the user databases in the organization. This collection is then piped to the Where-Object cmdlet, which picks out only those databases where the Online property is equal to False. The filtered collection is then piped to the ForEach-Object cmdlet, which takes each database in the collection and sets the Online property to True. Note that the collection of offline databases must be piped to the ForEach-Object cmdlet rather than the Set-CsUserDatabaseState cmdlet. That is because the latter cmdlet cannot directly accept pipelined information.

Copy Code
Get-CsUserDatabaseState | Where-Object {$_.Online -eq $False} | ForEach-Object {Set-CsUserDatabaseState -Identity $_.Identity -Online $True}

Detailed Description

Lync Server employs the user database (also known as the user store) to maintain presence and routing information for Lync Server users. The Set-CsUserDatabaseState cmdlet provides a way for you change the state of one or more user databases: you can use the cmdlet to take a database offline or to bring a disabled database back online.

Note that, by default, the firewall exceptions for SQL Server Express are not enabled when you install the Standard Edition of Lync Server. In turn, that means that you will not be able to run the Set-CsUserDatabaseState cmdlet from a remote instance of Windows PowerShell. That’s because your command will not be able to traverse the firewall and access the SQL Server Express database. You can still run the cmdlet locally (that is, on the Standard Edition server itself). However, to run the Set-CsUserDatabaseState cmdlet remotely you will need to manually enable the firewall exceptions for SQL Server Express.

Who can run this cmdlet: By default, members of the following groups are authorized to run the Set-CsUserDatabaseState cmdlet locally: RTCUniversalServerAdmins. 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 prompt:

Get-CsAdminRole | Where-Object {$_.Cmdlets –match "Set-CsUserDatabaseState"}


Parameter Required Type Description




Unique identifier of the user database whose online status is to be modified. For example: -Identity "".

You cannot use both Identity and RegistrarPool in the same command, nor can you use wildcards with either parameter.




When set to True ($True), makes a database available online. When set to False ($False), takes a database offline.




Fully qualified domain name (FQDN) of the Registrar pool hosting the user databases whose online status is to be modified. For example: -RegistrarPool

You cannot use both –Identity and –RegistrarPool in the same command, nor can you use wildcards with either parameter.




Prompts you for confirmation before executing the command.




Suppresses the display of any non-fatal error message that might arise when running the command.




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

Input Types

String. The Set-CsUserDatabaseState cmdlet accepts a string value representing the Identity of the user database to be updated.

Return Types

None. Instead, the Set-CsUserDatabaseState cmdlet modifies existing instances of the Microsoft.Rtc.Management.Xds.UserStoreState object.

See Also