dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Getting warning using Connection object from Connect-DbaInstance with Invoke-DbaQuery

Open garyhampson opened this issue 7 months ago • 6 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

When I use the connection object created by Connect-DbaInstance in my call to Invoke-DbaQuery, I get the following message:

WARNING: [15:46:13][Connect-DbaInstance] Additional parameters are passed in, but they will be ignored

I have confirmed that it is actually the call to Invoke-DbaQuery that is raising this warning, not the call that creates the Connection object itself. I know that I can use the -WarningAction SilentlyContinue, but that seems like a kludge. Any suggestions? Examples 8 and onwards from the Connect-DbaInstance documentation will exhibit this behavior.

Steps to Reproduce

PS D:\Code\dbatoolkit> $Conn = Connect-DbaInstance -SqlInstance SQLServerAG01.domain.local -MultiSubnetFailover -TrustServerCertificate
PS D:\Code\dbatoolkit> Invoke-DbaQuery -SqlInstance $Conn -Database master -Query "SELECT DB_NAME()"
WARNING: [15:46:13][Connect-DbaInstance] Additional parameters are passed in, but they will be ignored

Column1
-------
master


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

```powershell
PS D:\Code\dbatoolkit> Get-Module dbatools

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.1.30                dbatools                            {Select-DbaObject, Set-DbatoolsConfig, Add-DbaAgDatabase, Add

### Other details or mentions




### What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

### PowerShell Host Version

```powershell
PS D:\Code\dbatoolkit> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.14393
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

Microsoft SQL Server 2019 (RTM-CU32) (KB5054833) - 15.0.4430.1 (X64)   Feb 21 2025 17:28:26   Copyright (C) 2019 Microsoft Corporation  Standard Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor) 

### .NET Framework Version

.NET 9.0.4

garyhampson avatar May 12 '25 19:05 garyhampson

I just found the root cause for this in #9592 (see my comment: https://github.com/dataplat/dbatools/pull/9592#discussion_r2089643092).

I will try to work with @niphlod on a fix for this.

andreasjordan avatar May 14 '25 19:05 andreasjordan

Thanks @andreasjordan!

garyhampson avatar May 14 '25 21:05 garyhampson

hi all, looking into this right now

niphlod avatar May 15 '25 18:05 niphlod

hi @andreasjordan , @garyhampson , would you give https://github.com/dataplat/dbatools/pull/9667 a whirl and see if it fixes the issue ?

niphlod avatar May 15 '25 19:05 niphlod

this is now addressed into #9680

niphlod avatar May 27 '25 06:05 niphlod

Thank you @niphlod and @andreasjordan and apologies for not replying earlier (family holiday).

garyhampson avatar Jun 04 '25 18:06 garyhampson