-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
Comments
So I dug into it more. I think it is related to Get-DbaRegServer sqlmgmt | select -first 1 | connect-dbainstance -Database msdb | invoke-dbaquery -Query 'select db_name() d;' So it appears this code path needs to add dbatools/public/Connect-DbaInstance.ps1 Lines 654 to 687 in 55f5166
There is dbatools/public/Connect-DbaInstance.ps1 Lines 595 to 606 in 55f5166
|
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
toInvoke-DbaQuery
while specifying-Database
causesmaster
to be queried, even when another database is specified.Steps to Reproduce
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.
The text was updated successfully, but these errors were encountered: