-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlScriptQuery: Get-Module for SQLPS throws error #1928
Comments
Thanks for reporting this. Guess we need to add integration tests that runs with SQLPS as well. 🙂
On what line did you add that to? |
Hey @johlju what I meant in my suggestion is that I added in a very simple test simply trying to call
I couldn't get the time to discover exactly where in |
Ah, cool. I will figure it out. It was most likely one of the changed lines to support dbatools as a preferred module. I did not know |
It this line that fails.
It should check for So the line should be $loadedModuleName = (Get-Module -Name (Split-Path -Path $availableModuleName -Leaf) | Select-Object -First 1).Name @RDiegoli01 could you possible confirm this by changing that line in the file SqlServerDsc.psm1 on a node that fails? The line is part of the command |
@johlju tested your suggestion on a stack I had. It worked perfectly fine! |
Great. I sent in a PR with the change. Will merge and release as soon as the tests pass. |
) - `Import-SqlDscPreferredModule` - Now the command does not fail when checking if SQLPS is loaded into the session (issue #1928).
Problem description
When calling the attached DSC configuration, we see an error related to our
SqlScriptQuery
call.It looks like the target VM is trying to import the
SQLPS
module (from SQL Server 2022), but the Get-Module is passing bad parameters (see verbose logs).We caught this last week we were using
SqlServerDsc
16.2 which was working fine. Then our script updated it to 16.3 (released last week) and we started seeing this error.Verbose logs
DSC configuration
Suggested solution
Tested following exactly what the error message suggested:
-ListAvailable
parameter toGet-Module
and it worked-Name
(i.e.Get-Module -Name SQLPS
)SQL Server edition and version
SQL Server PowerShell modules
Operating system
PowerShell version
SqlServerDsc version
The text was updated successfully, but these errors were encountered: