diff --git a/public/Expand-DbaDbLogFile.ps1 b/public/Expand-DbaDbLogFile.ps1 index 21429747068..6d5ea8017c0 100644 --- a/public/Expand-DbaDbLogFile.ps1 +++ b/public/Expand-DbaDbLogFile.ps1 @@ -369,13 +369,13 @@ function Expand-DbaDbLogFile { # We don't have windows credentials here, so Resolve-DbaNetworkName has to respect that and work like Resolve-NetBiosName did before. $resolvedComputerName = Resolve-DbaComputerName -ComputerName $SqlInstance - $databases = $server.Databases | Where-Object IsAccessible + $databases = @($server.Databases | Where-Object IsAccessible) Write-Message -Level Verbose -Message "Number of databases found: $($databases.Count)." if ($Database) { - $databases = $databases | Where-Object Name -In $Database + $databases = @($databases | Where-Object Name -In $Database) } if ($ExcludeDatabase) { - $databases = $databases | Where-Object Name -NotIn $ExcludeDatabase + $databases = @($databases | Where-Object Name -NotIn $ExcludeDatabase) } #go through all databases @@ -686,7 +686,9 @@ function Expand-DbaDbLogFile { } | Select-DefaultView -ExcludeProperty LogFileCount } #foreach database } catch { - Stop-Function -Message "Logfile $logfile on database $dbName not processed. Error: $($_.Exception.Message). Line Number: $($_InvocationInfo.ScriptLineNumber)" -Continue + # No -Continue here: this block has no enclosing loop, so the continue would escape the command + # and eat an iteration of whatever loop the caller runs in (#10638). + Stop-Function -Message "Logfile $logfile on database $dbName not processed. Error: $($_.Exception.Message). Line Number: $($_.InvocationInfo.ScriptLineNumber)" } } diff --git a/tests/Expand-DbaDbLogFile.Tests.ps1 b/tests/Expand-DbaDbLogFile.Tests.ps1 index e4cd04f999f..0a96fde4c83 100644 --- a/tests/Expand-DbaDbLogFile.Tests.ps1 +++ b/tests/Expand-DbaDbLogFile.Tests.ps1 @@ -75,7 +75,8 @@ Describe $CommandName -Tag UnitTests { function Select-DefaultView { param( [Parameter(ValueFromPipeline)] - $InputObject + $InputObject, + $ExcludeProperty ) process { @@ -92,7 +93,9 @@ Describe $CommandName -Tag UnitTests { Mock Connect-DbaInstance { $script:mockServer } - Mock Measure-DbaDbVirtualLogFile { + function Measure-DbaDbVirtualLogFile { + param($SqlInstance, $Database) + $script:measureCallCount += 1 if ($script:measureCallCount -eq 1) {