DSCResources/SqlDatabases/SqlDatabases.schema.psm1
configuration SqlDatabases { param ( [Parameter()] [string] $DefaultInstanceName = 'MSSQLSERVER', [Parameter(Mandatory = $true)] [hashtable[]] $Values ) <# InstanceName = [string] Name = [string] [Collation = [string]] [CompatibilityLevel = [string]{ Version100 | Version110 | Version120 | Version130 | Version140 | Version150 | Version80 | Version90 }] [DependsOn = [string[]]] [Ensure = [string]{ Absent | Present }] [OwnerName = [string]] [PsDscRunAsCredential = [PSCredential]] [RecoveryModel = [string]{ BulkLogged | Full | Simple }] [ServerName = [string]] #> Import-DscResource -ModuleName SqlServerDsc -Name SqlDatabase foreach ($value in $Values) { if (-not $value.InstanceName) { $value.InstanceName = $DefaultInstanceName } if (-not $value.Ensure) { $value.Ensure = 'Present' } $executionName = "$($value.InstanceName)_$($value.Name -replace ' ','')" (Get-DscSplattedResource -ResourceName SqlDatabase -ExecutionName $executionName -Properties $value -NoInvoke).Invoke($value) } } |