Add-SqlDatabaseRoleMember

Adds a user or role to a database role.

Syntax

Add-SqlDatabaseRoleMember [[-sqlserver] <Object>] [-dbname] <Object> [-name] <String> [-rolename] <String> [<CommonParameters>]

Detailed Description

The Add-SqlDatabaseRoleMember function adds a user or role to the specified database role.

Related Commands

* Add-SqlDatabaseRoleMember

Parameters

Name Description Required? Pipeline Input Default Value
sqlserver    false  false   
dbname    true  false   
name    true  false   
rolename    true  false   

Input Type

None You cannot pipe objects to Add-SqlDatabaseRoleMember

Return Values

None This function does not generate any output.

Examples

EXAMPLE 1

Add-SqlDatabaseRoleMember "Z002\sql2k8" "pubs" "TestPSUnit" "TestPSUnitDBRole"
This command adds the TestUnit user to the TestPSUnitDBRole database role.

EXAMPLE 2

$database = Get-SqlDatabase "Z002\sql2k8" "pubs"
Add-SqlDatabaseRoleMember -dbname $database -name "TestPSUnit" -rolename "TestPSUnitDBRole" This command adds the TestUnit user to the TestPSUnitDBRole database role.