Add-SqlUser

Adds a new user to a database.

Syntax

Add-SqlUser [[-sqlserver] <Object>] [-dbname] <Object> [-name] <String> [[-login] <String>] [[-defaultSchema] <String>] [<CommonParameters>]

Detailed Description

The Add-SqlUser function adds a new user to the specified database.

Related Commands

* Add-SqlUser

Parameters

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

Input Type

None You cannot pipe objects to Add-SqlUser

Return Values

None This function does not generate any output.

Examples

EXAMPLE 1

Add-SqlUser "Z002\sql2k8" "pubs" "TestPSUnit"
This command adds the TestPSUnit login to the pubs database.

EXAMPLE 2

$database = Get-SqlDatabase "Z002\sql2k8" "pubs"
Add-SqlUser -dbname $database "TestPSUnit" This command adds the TestPSUnit login to the pubs database.