Copy-DbaDbQueryStoreOption fails due to parameter name mismatch
Before submitting a bug report:
- [X ] Ensure you are able to reproduce it on the latest released version (we release often)
- [X ] Verified this bug is not already reported in an issue
- [X ] Verified errors are not related to permissions
- [X ] Can reproduce in a clean PowerShell session (clean =
powershell -NoProfile)
Steps to Reproduce
$splat = @{
Source = $devInstance;
SourceDatabase = 'Warehouse';
Destination = $devInstance;
DestinationDatabase = 'Staging';
}
Copy-DbaDbQueryStoreOption @splat;
Expected Behavior
Copy of the QueryStore settings would happen
Actual Behavior
collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
Cause
This is due to Copy-DbaDbQueryStoreOption calling Get-DbaDbQueryStoreOption, then passing the resulting values to Set-DbaDbQueryStoreOption, but not using the correct parameter names.
Get's line 94 sets them as:
Select-DefaultView -InputObject $QSO -Property ComputerName, InstanceName, SqlInstance, Database, ActualState, DataFlushIntervalInSeconds, StatisticsCollectionIntervalInMinutes, MaxStorageSizeInMB, CurrentStorageSizeInMB, QueryCaptureMode, SizeBasedCleanupMode, StaleQueryThresholdInDays
and Copy sends them to Set as:
$SourceQSConfig = Get-DbaDbQueryStoreOption -SqlInstance $sourceServer -Database $SourceDatabase
...
$null = Set-DbaDbQueryStoreOption -SqlInstance $destinationServer -SqlCredential $DestinationSqlCredential `
-Database $db.name `
-State $SourceQSConfig.ActualState `
-FlushInterval $SourceQSConfig.FlushInterval `
-CollectionInterval $SourceQSConfig.CollectionInterval `
-MaxSize $SourceQSConfig.MaxSize `
-CaptureMode $SourceQSConfig.CaptureMode `
-CleanupMode $SourceQSConfig.CleanupMode `
-StaleQueryThreshold $SourceQSConfig.StaleQueryThreshold
$copyQueryStoreStatus.Status = "Successful"
Get using DataFlushIntervalInSeconds and Copy using FlushInterval instead. One of the functions needs the parameter names updated to match the other. Modifying Copy should have the least external impact as they're all internal and not displayed to the user like Get-DbaDbQueryStoreOption currently does.
Environmental data
PSVersion 5.1.16299.637