dbatools
dbatools copied to clipboard
Warning after run Get-Dbatoolsconfig or Find-DbaInstance on Windows Server 2016
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
WARNING: [13:39:16][<Unknown>] 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.
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 <X64> (Build 14393: ) (Hypervisor)
.NET Framework Version
.NET Framework 4.8.4718.0