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

Get-DbaHideInstance does not work on a system with named instance #9350

Open michele-tahay-kohera opened 1 month ago

michele-tahay-kohera commented 1 month ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

When running this command, you don't get results but also not any error as well

Get-DbaHideInstance -SqlInstance localhost\namedInstance1

You do get an error when you call it with the -EnableException parameter: image

The registry item is there all right, and my powershell session is running in admin mode image

It is possible that it is a permission issue, but then it should clearly state so in a warning/error message.

Steps to Reproduce

# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference

Get-DbaHideInstance -SqlInstance localhost\namedInstance1

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

2.1.14

Other details or mentions

I'm trying to test out dbachecks on my local machine with 2 (almost empty) named instances. This dbatools command is used in the check "HideInstance", and when it is included it doesn't fail but makes another test fail ("LoginPasswordExpiration") with a message "We Could not Connecto to $Instance"

What PowerShell host was used when producing this error

VS Code (integrated terminal)

PowerShell Host Version

Name Value


PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
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 2019 (RTM-GDR) (KB5035434) - 15.0.2110.4 (X64) Mar 12 2024 18:25:56 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 22631: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.9181.0

michele-tahay-kohera commented 1 month ago

Oh, in case you should wonder, it is the same thing with the other installed instance (sql 2022)

andreasjordan commented 1 month ago

As it is a local instance - do you run the command from an elevated PowerShell session? This should be needed to get to the registry.