Skip to content

Commit fccdb73

Browse files
authored
Import-SqlDscPreferredModule: Fix re-evaluate PSModulePath (#1938)
- `Import-SqlDscPreferredModule` - Now when parameter `Force` is passed the command correctly invoke `Get-SqlDscPreferredModule` using the parameter `Refresh`.
1 parent d296853 commit fccdb73

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Re-enable integration tests for dbatools.
2121
- Bumped dbatools to v2.0.1 for the integration tests.
2222

23+
### fixed
24+
25+
- `Import-SqlDscPreferredModule`
26+
- Now when parameter `Force` is passed the command correctly invoke
27+
`Get-SqlDscPreferredModule` using the parameter `Refresh`.
28+
2329
## [16.3.1] - 2023-05-06
2430

2531
### Changed

source/Public/Import-SqlDscPreferredModule.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function Import-SqlDscPreferredModule
6565
$getSqlDscPreferredModuleParameters.Name = @($Name, 'SQLPS')
6666
}
6767

68+
if ($PSBoundParameters.ContainsKey('Force'))
69+
{
70+
$getSqlDscPreferredModuleParameters.Refresh = $true
71+
}
72+
6873
$availableModuleName = Get-SqlDscPreferredModule @getSqlDscPreferredModuleParameters
6974

7075
if ($Force.IsPresent)

tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ Describe 'Import-SqlDscPreferredModule' -Tag 'Public' {
236236
It 'Should import the SqlServer module without throwing' {
237237
{ Import-SqlDscPreferredModule -Force } | Should -Not -Throw
238238

239-
Should -Invoke -CommandName Get-SqlDscPreferredModule -Exactly -Times 1 -Scope It
239+
Should -Invoke -CommandName Get-SqlDscPreferredModule -ParameterFilter {
240+
$PesterBoundParameters.ContainsKey('Refresh') -and $Refresh -eq $true
241+
} -Exactly -Times 1 -Scope It
242+
240243
Should -Invoke -CommandName Push-Location -Exactly -Times 1 -Scope It
241244
Should -Invoke -CommandName Pop-Location -Exactly -Times 1 -Scope It
242245
Should -Invoke -CommandName Remove-Module -Exactly -Times 1 -Scope It

0 commit comments

Comments
 (0)