dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Register-DbatoolsConfig dont register in Registry

Open ksl28 opened this issue 3 years ago • 3 comments

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

ksl28 avatar May 24 '22 13:05 ksl28

Any update on this issue? I have been experiencing similar problems.

DatabaseDylan avatar Jun 10 '22 16:06 DatabaseDylan

Are you running the command as Admin?

mattcargile avatar Jul 12 '22 15:07 mattcargile

@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.

DatabaseDylan avatar Jul 12 '22 15:07 DatabaseDylan

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

andreasjordan avatar Oct 24 '22 14:10 andreasjordan

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 avatar Oct 26 '22 07:10 potatoqualitee

@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.

jpomfret avatar Dec 30 '22 14:12 jpomfret

It would also make a good candidate for an example in the Register command's CBH 😉

wsmelton avatar Jan 17 '23 01:01 wsmelton

Good thought - created a PR to add this example

jpomfret avatar Feb 13 '23 17:02 jpomfret

Closing this issue, doc change will be included in 2.0 release.

wsmelton avatar Feb 15 '23 00:02 wsmelton