Register-DbatoolsConfig dont register in Registry
Verified issue does not already exist?
Yes
What error did you receive?
There is no error output, but config is never applied.
Execute the following commands to replicate Set-DbatoolsConfig -FullName logging.errorlogenabled -Value $false | Register-DbatoolsConfig -Scope SystemMandatory Get-DbatoolsConfig -FullName logging.errorlogenabled The value is now False, close your Powershell core process, and start it again. Then execute this command Get-DbatoolsConfig -FullName logging.errorlogenabled The value is now true again
Ive tried using Unregister-DbatoolsConfig, Reset-DbatoolsConfig - but none of them works for this issue.
If i manually create the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsPowerShell\dbatools\Config\Enforced\logging.errorlogenabled with the value Bool:false and then restart Powershell core, then it works as expected.
Steps to Reproduce
Set-DbatoolsConfig -FullName logging.errorlogenabled -Value $false | Register-DbatoolsConfig -Scope SystemMandatory
Get-DbatoolsConfig -FullName logging.errorlogenabled
## The value is now False, close your Powershell core process, and start it again. Then execute this command
Get-DbatoolsConfig -FullName logging.errorlogenabled
## The value is now true again
Are you running the latest release?
Yes
Other details or mentions
Already mentioned in the first section.
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe), VS Code (terminal)
PowerShell Host Version
PSVersion 7.2.4 PSEdition Core GitCommitId 7.2.4 OS Microsoft Windows 10.0.22000 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
SQL Server Edition and Build number
No SQL server is involved in this process
.NET Framework Version
.NET 6.0.5
Any update on this issue? I have been experiencing similar problems.
Are you running the command as Admin?
@mattcargile yes, actually funny you answered this today as I am just now revisiting. I ended up creating the keys manually in the registry under the service account that runs my service. Nothing else seems to work/stick.
You code Set-DbatoolsConfig -FullName logging.errorlogenabled -Value $false | Register-DbatoolsConfig -Scope SystemMandatory does not what you expect. The Set- command does not return anything, so Register-DbatoolsConfig is not run. You must use -PassThru with the Set- command:
Set-DbatoolsConfig -FullName logging.errorlogenabled -Value $false -PassThru | Register-DbatoolsConfig -Scope SystemMandatory
OHHHHHHHHHHHHHHHHHHH is that how you do it! Okay, I'm betting that this was done to speed up the module import. Thank you andreas, this was driving me crazy. I'll include this tip in 2.0 since i'll be telling people how to register the encryption stuff.
@potatoqualitee - I've added the following to my dbatools 2.0 post that will be live at http://jesspomfret.com/dbatools-2-0/ once it's released and the post is live.
Note: The -PassThru parameter on Set-DbatoolsConfig is vital for these settings to be persisted as without that parameter nothing is passed down the pipeline from the Set command.
It would also make a good candidate for an example in the Register command's CBH 😉
Good thought - created a PR to add this example
Closing this issue, doc change will be included in 2.0 release.