diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc600906..8131255ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- SqlTraceFlag + - Fixed Assembly not loaded error + ([issue #1680](https://github.com/dsccommunity/SqlServerDsc/issues/1680)). + ### Changed - SqlLogin diff --git a/source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1 b/source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1 index 24c0bdf28..63e3b61df 100644 --- a/source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1 +++ b/source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1 @@ -33,6 +33,9 @@ function Get-TargetResource $InstanceName ) + # Import SqlServer module. + Import-SQLPSModule + Write-Verbose -Message ( $script:localizedData.GetConfiguration -f $InstanceName ) @@ -145,6 +148,9 @@ function Set-TargetResource $RestartTimeout = 120 ) + # Import SqlServer module. + Import-SQLPSModule + Write-Verbose -Message ( $script:localizedData.SetConfiguration -f $InstanceName ) diff --git a/tests/Unit/DSC_SqlTraceFlag.Tests.ps1 b/tests/Unit/DSC_SqlTraceFlag.Tests.ps1 index 7d5375c9f..a8c8e4a54 100644 --- a/tests/Unit/DSC_SqlTraceFlag.Tests.ps1 +++ b/tests/Unit/DSC_SqlTraceFlag.Tests.ps1 @@ -167,6 +167,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf return @($mockServerObject) } Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -ParameterFilter $mockNewObject_ParameterFilter_RealServerName -Verifiable + Mock -CommandName Import-SQLPSModule } Context 'For the default instance' { @@ -353,6 +354,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf return @($mockServerObject) } Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -Verifiable + Mock -CommandName Import-SQLPSModule } Context 'When the system is not in the desired state and TraceFlags is empty' { @@ -646,6 +648,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf } Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -Verifiable Mock -CommandName Restart-SqlService -ModuleName $script:dscResourceName -Verifiable + Mock -CommandName Import-SQLPSModule } Context 'When the system is not in the desired state and ensure is set to Absent' {