Skip to content

Commit

Permalink
Changes to SqlScript
Browse files Browse the repository at this point in the history
- Added en-US localization (issue dsccommunity#624).
  • Loading branch information
johlju committed Apr 22, 2019
1 parent 7a05776 commit cecdb32
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
`Invoke-SqlScript` so that `PRINT` statements is outputted correctly
when verbose output is requested, e.g
`Start-DscConfiguration -Verbose`.
- Added en-US localization ([issue #624](https://github.com/PowerShell/SqlServerDsc/issues/624)).
- Changes to SqlScriptQuery
- Correctly passes the `$VerbosePreference` to the helper function
`Invoke-SqlScript` so that `PRINT` statements is outputted correctly
Expand Down
26 changes: 26 additions & 0 deletions DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath '
$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlScript'

<#
.SYNOPSIS
Returns the current state of the SQL Server features.
Expand Down Expand Up @@ -90,6 +92,10 @@ function Get-TargetResource
ErrorAction = 'Stop'
}

Write-Verbose -Message (
$script:localizedData.ExecutingGetScript -f $GetFilePath, $ServerInstance
)

$result = Invoke-SqlScript @invokeParameters

$getResult = Out-String -InputObject $result
Expand Down Expand Up @@ -177,6 +183,10 @@ function Set-TargetResource
$Variable
)

Write-Verbose -Message (
$script:localizedData.ExecutingSetScript -f $SetFilePath, $ServerInstance
)

$invokeParameters = @{
ServerInstance = $ServerInstance
InputFile = $SetFilePath
Expand Down Expand Up @@ -261,8 +271,16 @@ function Test-TargetResource
$Variable
)

Write-Verbose -Message (
$script:localizedData.TestingConfiguration
)

try
{
Write-Verbose -Message (
$script:localizedData.ExecutingTestScript -f $TestFilePath, $ServerInstance
)

$invokeParameters = @{
ServerInstance = $ServerInstance
InputFile = $TestFilePath
Expand All @@ -277,10 +295,18 @@ function Test-TargetResource

if ($null -eq $result)
{
Write-Verbose -Message (
$script:localizedData.InDesiredState
)

return $true
}
else
{
Write-Verbose -Message (
$script:localizedData.NotInDesiredState
)

return $false
}
}
Expand Down
10 changes: 10 additions & 0 deletions DSCResources/MSFT_SqlScript/en-US/MSFT_SqlScript.strings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Localized resources for SqlSetup

ConvertFrom-StringData @'
ExecutingGetScript = Executing the Get script from the file path '{0}' on the instance '{1}'.
ExecutingSetScript = Executing the Set script from the file path '{0}' on the instance '{1}'.
ExecutingTestScript = Executing the Test script from the file path '{0}' on the instance '{1}'.
TestingConfiguration = Determines if the configuration in the Set script is in desired state.
InDesiredState = The configuration is in desired state.
NotInDesiredState = The configuration is not in desired state.
'@

0 comments on commit cecdb32

Please sign in to comment.