Skip to content

Commit

Permalink
Import-SqlDscPreferredModule: Fix checking that SQLPS is loaded (#1929
Browse files Browse the repository at this point in the history
)

- `Import-SqlDscPreferredModule`
  - Now the command does not fail when checking if SQLPS is loaded into the
    session (issue #1928).
  • Loading branch information
johlju authored May 6, 2023
1 parent 753c556 commit d9a84f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(tested v21.0.17099). The parameter will be ignored if SQLPS module will be
used.

### Fixed

- `Import-SqlDscPreferredModule`
- Now the command does not fail when checking if SQLPS is loaded into the
session ([issue #1928](https://github.com/dsccommunity/SqlServerDsc/issues/1928)).

## [16.3.0] - 2023-04-26

### Remove
Expand Down
8 changes: 6 additions & 2 deletions source/Public/Import-SqlDscPreferredModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ function Import-SqlDscPreferredModule
{
if (-not $Force.IsPresent)
{
# Check if the preferred module is already loaded into the session.
$loadedModuleName = (Get-Module -Name $availableModuleName | Select-Object -First 1).Name
<#
Check if the preferred module is already loaded into the session.
If the module name is a path the leaf part must be used, which is
the module name.
#>
$loadedModuleName = (Get-Module -Name (Split-Path -Path $availableModuleName -Leaf) | Select-Object -First 1).Name

if ($loadedModuleName)
{
Expand Down

0 comments on commit d9a84f4

Please sign in to comment.