Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piping from Get-DbaRegServer to Invoke-DbaQuery while specifying -Database causes master to be queried, even when another database is specified #9541

Open
ReeceGoding opened this issue Nov 6, 2024 · 0 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@ReeceGoding
Copy link
Contributor

ReeceGoding commented Nov 6, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

You're most likely to get "Invalid object name 'YourSchema.YourTable'". This happens because piping from Get-DbaRegServer to Invoke-DbaQuery while specifying -Database causes master to be queried, even when another database is specified.

Steps to Reproduce

Get-DbaRegServer | Invoke-DbaQuery -Database MyDb -Query "SELECT * FROM dbo.TableOnlyInMyDb"`

This issue happens even if you filter Get-DbaRegServer down to only return one server.

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

Tested on 2.1.23

Other details or mentions

Piping in the server names as strings does not cause this issue. You have to pipe from Get-DbaRegServer.

-Verbose adds no more useful information.

Make sure that you don't hit this issue, which I'm pretty sure my PR didn't fix.

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

5.1.19041.5007

SQL Server Edition and Build number

Doesn't seem to matter.

.NET Framework Version

Very recent.

@ReeceGoding ReeceGoding added bugs life triage required New issue that has not been reviewed by maintainers labels Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant