Skip to content

Assert‑SqlDscLogin

dscbot edited this page Dec 5, 2025 · 2 revisions

SYNOPSIS

Assert that the specified SQL Server principal exists as a login.

SYNTAX

Assert-SqlDscLogin [-ServerObject] <Server> [-Name] <String> 
 [<CommonParameters>]

DESCRIPTION

This command asserts that the specified SQL Server principal exists as a login. If the principal does not exist as a login, a terminating error is thrown.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Assert-SqlDscLogin -Name 'MyLogin'

Asserts that the principal 'MyLogin' exists as a login.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Assert-SqlDscLogin -ServerObject $serverObject -Name 'MyLogin'

Asserts that the principal 'MyLogin' exists as a login.

PARAMETERS

-Name

Specifies the name of the principal that needs to exist as a login.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.SqlServer.Management.Smo.Server

Accepts a SQL Server server object via the pipeline.

OUTPUTS

None.

NOTES

This command throws a terminating error if the specified SQL Server principal does not exist as a SQL server login.

RELATED LINKS

Home

Commands

How-to

Resources

Usage

Clone this wiki locally