Closed jay-butler closed 5 years ago
I have been doing more troubleshooting with this one. I have tried uninstalling dbatools and forcing an install of various older versions. In some cases, VS works, but in most it throws the above errors on Import-Module. Next, I am going to uninstall PowerShell Tools for Visual Studio extension and re-install it.
I use PoshTools but not with VS 2017 so can't verify this right off. I'm on VS 2019 and it has no issues that I have seen.
Do you have the same issue if you repeat your test using PoshTools in VS Code?
@jay-butler - can you install 1.0.26 is any other way? Either via Save-Module or by downloading the nuget and extracting from dbatools.io/gallery? This generally happens when the installer failed.
Thanks for the quick responses. @wsmelton I actually did test this on a coworker's machine using VS17 Pro and on my box in PowerShell ISE. But, I did not have VS Code installed on my box yet. @potatoqualitee I went through uninstalling and reinstalling manually as you suggested, but the problem persisted. That got me thinking about what could have changed. I was just making some relatively minor changes in my code which included renaming some variable and functions to be a bit more descriptive. I had inadvertently caused a function naming collision between one of the functions in my code with one of the private functions in dbatools. We both had a Write-Message function. Once I renamed my function to something else, the error was gone.
Thanks again for the quick responses. I was stuck scratching my head. You guys got me thinking in a way that got me to the solution.
Issue is resolved. One of the private functions in the dbatools (Write-Message) had a name collision with one of the functions in my own module. I had assumed that all dbatools functions used the Verb-Dba prefix convention, but now realize that only applies to the public/exported functions. I changed the naming convention in my own module to prevent further collisions.
excellent news, thanks for the update ⭐️
Environmental information
dbatools Module version:
SQL Server:
Report
Host used
[ ] powershell.exe
[ ] ISE
[ ] VS Code
[x] Other (please specify) Visual Studio 2017 Community If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe
[ ] Still buggy in powershell.exe
Errors Received
Steps to Reproduce
Running a debug session in VS17 Community with the PowerShell Tools for Visual Studio installed, ran a script that had just completed initializing (created a log file, wrote a few messages). The Import-Module command produces a few errors resulting in the module not being loaded correctly.
Expected Behavior
Prior versions of the dbatools module had loaded without error. Worked around error by installing dbatools 1.0.20 side-byside with 1.0.26 and forced he older version load by setting the -MaximumVersion parameter. Older module loaded without error.
Actual Behavior
Version 1.0.26 produced the following error when imported in VS17. It did not produce any error when loaded from the powershell.exe command line. Version 1.0.20 did not produce any errors in VS or on the command line. Register-DbaRunspace : A parameter cannot be found that matches parameter name 'Target'.