Set‑SqlDscDatabase - dsccommunity/SqlServerDsc GitHub Wiki
Sets properties of a database in a SQL Server Database Engine instance.
Set-SqlDscDatabase -ServerObject <Server> -Name <String> [-Collation <String>] [-CompatibilityLevel <String>]
[-RecoveryModel <String>] [-OwnerName <String>] [-Force] [-Refresh] [-PassThru]
[-WhatIf] [-Confirm] [<CommonParameters>]
Set-SqlDscDatabase -DatabaseObject <Database> [-Collation <String>] [-CompatibilityLevel <String>]
[-RecoveryModel <String>] [-OwnerName <String>] [-Force] [-PassThru]
[-WhatIf] [-Confirm] [<CommonParameters>]
This command sets properties of a database in a SQL Server Database Engine instance.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$databaseObject = $serverObject | Get-SqlDscDatabase -Name 'MyDatabase'
$databaseObject | Set-SqlDscDatabase -RecoveryModel 'Simple'
Sets the recovery model of the database named MyDatabase to Simple.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Set-SqlDscDatabase -Name 'MyDatabase' -OwnerName 'sa' -Force
Sets the owner of the database named MyDatabase to sa without prompting for confirmation.
The name of the SQL collation to set for the database.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The version of the SQL compatibility level to set for the database.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
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
Specifies that the database 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
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
Specifies the name of the login that should be the owner of the database.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
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
The recovery model to be set for the database.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
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
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
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
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
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.