dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.39k stars 787 forks source link

Warning after run Get-Dbatoolsconfig or Find-DbaInstance on Windows Server 2016 #9382

Open rupsan04 opened 3 weeks ago

rupsan04 commented 3 weeks ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

WARNING: [13:39:16][] Failed to apply configuration 'Import.AlwaysBuildLibrary' | The term 'else' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Steps to Reproduce

Get-DbatoolsConfig or Find-DbaInstance -ComputerName server1

Please confirm that you are running the most recent version of dbatools

2.1.16

Other details or mentions

The warning occurs after updating dbatools version 2.0.4 to 2.1.16 when run e.g. Get-DbatoolsConfig in a new PowerShell session. I am pretty sure that the following adjustment to private/configurations/settings/import.ps1 will fix this problem.

old new

I'm pretty sure that two else directly after each other aren't allowed in powershell. That's why I removed the first else. Now the if else would also make sense and not set the registry key with the same value if $args[0] is true or false.

I have tested this by placing the import.ps1 under C:\Program Files\WindowsPowerShell\Modules\dbatools\2.1.16\private\configurations\settings and making the change described above. It works!

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe), Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2017 (RTM-CU31-GDR) (KB5029376) - 14.0.3465.1 (X64) Jul 30 2023 15:31:58 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.4718.0

niphlod commented 3 weeks ago

looks like a duck, swims like a duck, and quacks like a duck, so it's probably a bug.

I concur with @rupsan04 fix but I'm wary around import.ps1, @potatoqualitee what do you think ?

gabeKay commented 1 week ago

What is the status of the case? I have a huge environment where InsecureConnection was set and 2.1.18 was rolled out. Now certificates have been set up and after the config changes I also have this message in the logs. Editing all Modules is not an option ;) But thanks @rupsan04 for solution. It worked on testing environment