dsccommunity / SqlServerDsc

This module contains DSC resources for deployment and configuration of Microsoft SQL Server.
MIT License
360 stars 227 forks source link

`Invoke-SqlDscQuery`: `InstanceName` always set to default value in should process messages #1918

Closed johlju closed 1 year ago

johlju commented 1 year ago

When the command is called using the parameter set ByServerObject the parameter InstanceName is always set to the default value because $InstanceName is not changed according to the passed ServerObject.

https://github.com/dsccommunity/SqlServerDsc/blob/3e81805a4f76429822b1378d345084c73236173e/source/Public/Invoke-SqlDscQuery.ps1#L187-L188

Suggest adding the following in the begin-block.

if ($PSCmdlet.ParameterSetName -eq 'ByServerObject')
{
    $InstanceName = $ServerObject.InstanceName
}