Test‑SqlDscDatabase - dsccommunity/SqlServerDsc GitHub Wiki
Tests if a database on a SQL Server Database Engine instance is in the desired state.
Test-SqlDscDatabase [-ServerObject] <Server> [-Name] <String> [[-Ensure] <String>] [[-Collation] <String>]
[[-CompatibilityLevel] <String>] [[-RecoveryModel] <String>] [[-OwnerName] <String>] [-Refresh]
[<CommonParameters>]
This command tests if a database on a SQL Server Database Engine instance is in the desired state.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscDatabase -Name 'MyDatabase' -Ensure 'Present'
Tests if the database named MyDatabase exists.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscDatabase -Name 'MyDatabase' -Ensure 'Present' -RecoveryModel 'Simple' -OwnerName 'sa'
Tests if the database named MyDatabase exists and has the specified recovery model and owner.
The name of the SQL collation that the database should have.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe version of the SQL compatibility level that the database should have.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseWhen set to 'Present', the database must exist. When set to 'Absent', the database must not exist.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: Present
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the name of the database to test.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the name of the login that should be the owner of the database.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe recovery model that the database should have.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies that the ServerObject's databases should be refreshed before testing the database state. This is helpful when databases could have been modified outside of the ServerObject, for example through T-SQL. But on instances with a large amount of databases it might be better to make sure the ServerObject is recent enough.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies 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: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.