Add-SqlLogin

Adds a login to a SQL Server.

Syntax

Add-SqlLogin [-sqlserver] <Object> [-name] <String> [[-password] <String>] [[-logintype] {WindowsUser | WindowsGroup | SqlLogin | Certificate | AsymmetricKey}] [[-DefaultDatabase] <String>] [[-PasswordExpirationEnabled]] [[-PasswordPolicyEnforced]] [<CommonParameters>]

Detailed Description

The Add-SqlLogin function adds a new login to the specified SQL server.

Related Commands

* Add-SqlLogin

Parameters

Name Description Required? Pipeline Input Default Value
sqlserver    true  false   
name    true  false   
password    false  false   
logintype    false  false   
DefaultDatabase    false  false   
PasswordExpirationEnabled    false  false   
PasswordPolicyEnforced    false  false   

Input Type

None You cannot pipe objects to Add-SqlLogin

Return Values

None This function does not generate any output.

Examples

EXAMPLE 1

Add-SqlLogin "Z002\sql2k8" "TestPSUnit" "SQLPSXTesting" 'SqlLogin'
This command adds the TestPSUnit login to the Z002\sql2k8 server.

EXAMPLE 2

$server = Get-SqlServer "Z002\sql2k8"
Add-SqlLogin $server "TestPSUnit" "SQLPSXTesting" 'SqlLogin'
This command adds the TestPSUnit login to the Z002\sql2k8 server.