Skip to content

Test‑SqlDscIsDatabasePrincipal

dscbot edited this page Oct 26, 2024 · 1 revision

SYNOPSIS

Returns whether the database principal exist.

SYNTAX

Test-SqlDscIsDatabasePrincipal [-ServerObject] <Server> [-DatabaseName] <String> [-Name] <String>
 [-ExcludeUsers] [-ExcludeRoles] [-ExcludeFixedRoles] [-ExcludeApplicationRoles]
 [<CommonParameters>]

DESCRIPTION

Returns whether the database principal exist.

EXAMPLES

EXAMPLE 1

$serverInstance = Connect-SqlDscDatabaseEngine
Test-SqlDscIsDatabasePrincipal -ServerObject $serverInstance -DatabaseName 'MyDatabase' -Name 'MyPrincipal'

Returns $true if the principal exist in the database, if not $false is returned.

EXAMPLE 2

$serverInstance = Connect-SqlDscDatabaseEngine
Test-SqlDscIsDatabasePrincipal -ServerObject $serverInstance -DatabaseName 'MyDatabase' -Name 'MyPrincipal' -ExcludeUsers

Returns $true if the principal exist in the database and is not a user, if not $false is returned.

EXAMPLE 3

$serverInstance = Connect-SqlDscDatabaseEngine
Test-SqlDscIsDatabasePrincipal -ServerObject $serverInstance -DatabaseName 'MyDatabase' -Name 'MyPrincipal' -ExcludeRoles

Returns $true if the principal exist in the database and is not a role, if not $false is returned.

EXAMPLE 4

$serverInstance = Connect-SqlDscDatabaseEngine
Test-SqlDscIsDatabasePrincipal -ServerObject $serverInstance -DatabaseName 'MyDatabase' -Name 'MyPrincipal' -ExcludeFixedRoles

Returns $true if the principal exist in the database and is not a fixed role, if not $false is returned.

EXAMPLE 5

$serverInstance = Connect-SqlDscDatabaseEngine
Test-SqlDscIsDatabasePrincipal -ServerObject $serverInstance -DatabaseName 'MyDatabase' -Name 'MyPrincipal' -ExcludeApplicationRoles

Returns $true if the principal exist in the database and is not a application role, if not $false is returned.

PARAMETERS

-DatabaseName

Specifies the SQL database name.

Type: String
Parameter Sets: (All)
Aliases:

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

-ExcludeApplicationRoles

Specifies that fixed application roles should not be evaluated for the specified name.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ExcludeFixedRoles

Specifies that fixed roles should not be evaluated for the specified name.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ExcludeRoles

Specifies that database roles should not be evaluated for the specified name. This will also exclude fixed roles.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ExcludeUsers

Specifies that database users should not be evaluated.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Name

Specifies the name of the database principal.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
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

OUTPUTS

[System.Boolean]

NOTES

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally