Skip to content

Set‑SqlDscDatabaseDefault

dscbot edited this page Sep 7, 2025 · 1 revision

SYNOPSIS

Sets default objects of a database in a SQL Server Database Engine instance.

SYNTAX

ServerObject

Set-SqlDscDatabaseDefault -ServerObject <Server> -Name <String> [-DefaultFileGroup <String>]
 [-DefaultFileStreamFileGroup <String>] [-DefaultFullTextCatalog <String>] [-Force] [-Refresh] [-PassThru]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DatabaseObject

Set-SqlDscDatabaseDefault -DatabaseObject <Database> [-DefaultFileGroup <String>]
 [-DefaultFileStreamFileGroup <String>] [-DefaultFullTextCatalog <String>] [-Force] [-PassThru]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This command sets default objects of a database in a SQL Server Database Engine instance. It can set the default filegroup, default FILESTREAM filegroup, and default Full-Text catalog using SMO methods.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$databaseObject = $serverObject | Get-SqlDscDatabase -Name 'MyDatabase'
$databaseObject | Set-SqlDscDatabaseDefault -DefaultFileGroup 'MyFileGroup'

Sets the default filegroup of the database named MyDatabase to MyFileGroup.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Set-SqlDscDatabaseDefault -Name 'MyDatabase' -DefaultFullTextCatalog 'MyCatalog' -Force

Sets the default Full-Text catalog of the database named MyDatabase to MyCatalog without prompting for confirmation.

EXAMPLE 3

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$databaseObject = $serverObject | Get-SqlDscDatabase -Name 'MyDatabase'
$databaseObject | Set-SqlDscDatabaseDefault -DefaultFileGroup 'DataFileGroup' -DefaultFileStreamFileGroup 'FileStreamFileGroup' -DefaultFullTextCatalog 'FTCatalog'

Sets multiple default objects for the database named MyDatabase.

PARAMETERS

-DatabaseObject

Specifies a database object to modify.

Type: Database
Parameter Sets: DatabaseObject
Aliases:

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

-DefaultFileGroup

Sets the default filegroup for the database. The filegroup must exist in the database.

Type: String
Parameter Sets: (All)
Aliases:

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

-DefaultFileStreamFileGroup

Sets the default FILESTREAM filegroup for the database. The filegroup must exist in the database.

Type: String
Parameter Sets: (All)
Aliases:

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

-DefaultFullTextCatalog

Sets the default Full-Text catalog for the database. The catalog must exist in the database.

Type: String
Parameter Sets: (All)
Aliases:

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

-Force

Specifies that the database defaults should be modified without any confirmation.

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 to be modified.

Type: String
Parameter Sets: ServerObject
Aliases:

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

-PassThru

Specifies that the database object should be returned after modification.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Refresh

Specifies that the ServerObject's databases should be refreshed before modifying the database object. 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, or pass in DatabaseObject.

Type: SwitchParameter
Parameter Sets: ServerObject
Aliases:

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

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: ServerObject
Aliases:

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
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

Server object accepted from the pipeline (ServerObject parameter set).

Microsoft.SqlServer.Management.Smo.Database

Database object accepted from the pipeline (DatabaseObject parameter set).

OUTPUTS

None. But when PassThru is specified the output is [Microsoft.SqlServer.Management.Smo.Database].

NOTES

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally