-
Notifications
You must be signed in to change notification settings - Fork 225
SqlDatabaseDefaultLocation
dscbot edited this page Oct 26, 2024
·
11 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
InstanceName | Key | String | The name of the SQL Server instance to be configured. | |
Type | Key | String | The type of database default location to be configured. |
Data , Log , Backup
|
Path | Required | String | The path to the default directory to be set for the type specified in the parameter Type. | |
ServerName | Write | String | The host name of the SQL Server to be configured. Default value is the current computer name. | |
RestartService | Write | Boolean | If set to $true then SQL Server and dependent services will be restarted if a change to the configuration is made. The default value is $false . |
|
ProcessOnlyOnActiveNode | Write | Boolean | Specifies that the resource will only determine if a change is needed if the target node is the active host of the SQL Server instance. | |
IsActiveNode | Read | Boolean | Returns if the current node is actively hosting the SQL Server instance. |
The SqlDatabaseDefaultLocation
DSC resource is used to configure default
locations for user databases. The types of default locations that can be
changed are Data, Log, and Backup. For more information about database
default locations, please read the article View or Change the Default Locations for Data and Log Files.
- Target machine must be running Windows Server 2012 or later.
- Target machine must be running SQL Server Database Engine 2012 or later.
All issues are not listed here, see here for all open issues.
This example shows how to manage database default locations for Data, Logs, and Backups for SQL Server.
In the event this is applied to a Failover Cluster Instance (FCI), the ProcessOnlyOnActiveNode property will tell the Test-TargetResource function to evaluate if any changes are needed if the node is actively hosting the SQL Server Instance.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Data'
{
ServerName = 'sqltest.company.local'
InstanceName = 'DSC'
ProcessOnlyOnActiveNode = $true
Type = 'Data'
Path = 'C:\Program Files\Microsoft SQL Server'
PsDscRunAsCredential = $SqlAdministratorCredential
}
SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Log'
{
ServerName = 'sqltest.company.local'
InstanceName = 'DSC'
ProcessOnlyOnActiveNode = $true
Type = 'Log'
Path = 'C:\Program Files\Microsoft SQL Server'
PsDscRunAsCredential = $SqlAdministratorCredential
}
SqlDatabaseDefaultLocation 'Set_SqlDatabaseDefaultDirectory_Backup'
{
ServerName = 'sqltest.company.local'
InstanceName = 'DSC'
ProcessOnlyOnActiveNode = $true
Type = 'Backup'
Path = 'C:\Program Files\Microsoft SQL Server'
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
- Add-SqlDscNode
- Add-SqlDscTraceFlag
- Complete-SqlDscFailoverCluster
- Complete-SqlDscImage
- Connect-SqlDscDatabaseEngine
- ConvertFrom-SqlDscDatabasePermission
- ConvertFrom-SqlDscServerPermission
- ConvertTo-SqlDscDatabasePermission
- ConvertTo-SqlDscServerPermission
- Disable-SqlDscAudit
- Disconnect-SqlDscDatabaseEngine
- Enable-SqlDscAudit
- Get-SqlDscAudit
- Get-SqlDscConfigurationOption
- Get-SqlDscDatabasePermission
- Get-SqlDscManagedComputer
- Get-SqlDscManagedComputerService
- Get-SqlDscPreferredModule
- Get-SqlDscServerPermission
- Get-SqlDscStartupParameter
- Get-SqlDscTraceFlag
- Import-SqlDscPreferredModule
- Initialize-SqlDscRebuildDatabase
- Install-SqlDscServer
- Invoke-SqlDscQuery
- New-SqlDscAudit
- Remove-SqlDscAudit
- Remove-SqlDscNode
- Remove-SqlDscTraceFlag
- Repair-SqlDscServer
- Save-SqlDscSqlServerMediaFile
- Set-SqlDscAudit
- Set-SqlDscDatabasePermission
- Set-SqlDscServerPermission
- Set-SqlDscStartupParameter
- Set-SqlDscTraceFlag
- Test-SqlDscIsDatabasePrincipal
- Test-SqlDscIsLogin
- Test-SqlDscIsSupportedFeature
- Uninstall-SqlDscServer
- SqlAG
- SqlAGDatabase
- SqlAgentAlert
- SqlAgentFailsafe
- SqlAgentOperator
- SqlAGListener
- SqlAGReplica
- SqlAlias
- SqlAlwaysOnService
- SqlAudit
- SqlConfiguration
- SqlDatabase
- SqlDatabaseDefaultLocation
- SqlDatabaseMail
- SqlDatabaseObjectPermission
- SqlDatabasePermission
- SqlDatabaseRole
- SqlDatabaseUser
- SqlEndpoint
- SqlEndpointPermission
- SqlLogin
- SqlMaxDop
- SqlMemory
- SqlPermission
- SqlProtocol
- SqlProtocolTcpIp
- SqlReplication
- SqlRole
- SqlRS
- SqlRSSetup
- SqlScript
- SqlScriptQuery
- SqlSecureConnection
- SqlServiceAccount
- SqlSetup
- SqlTraceFlag
- SqlWaitForAG
- SqlWindowsFirewall