diff --git a/functions/Get-DbaServerRoleMember.ps1 b/functions/Get-DbaServerRoleMember.ps1 index 8e2f2ba9dd..4a7c340f0d 100644 --- a/functions/Get-DbaServerRoleMember.ps1 +++ b/functions/Get-DbaServerRoleMember.ps1 @@ -81,7 +81,7 @@ function Get-DbaServerRoleMember { param ( [parameter(Position = 0, Mandatory, ValueFromPipeline)] [Alias('ServerInstance', 'SqlServer')] - [DbaInstance[]]$SqlInstance, + [DbaInstanceParameter[]]$SqlInstance, [Alias('Credential')] [PSCredential]$SqlCredential, [string[]]$ServerRole, @@ -105,9 +105,12 @@ function Get-DbaServerRoleMember { $roles = $server.Roles if (Test-Bound -ParameterName 'Login') { - $logins = Get-DbaLogin -SqlInstance $instance -Login $Login + try { + $logins = Get-DbaLogin -SqlInstance $server -Login $Login -EnableException + } catch { + Stop-Function -Message "Issue gathering login details" -ErrorRecord $_ -Target $instance + } Write-Message -Level 'Verbose' -Message "Filtering by logins: $($logins -join ', ')" - foreach ($l in $logins) { $loginRoles += $l.ListMembers() } diff --git a/tests/appveyor.SQL2017.ps1 b/tests/appveyor.SQL2017.ps1 index 3816cec106..b9e9720843 100644 --- a/tests/appveyor.SQL2017.ps1 +++ b/tests/appveyor.SQL2017.ps1 @@ -28,7 +28,6 @@ Write-Host -Object "$indent Starting $instance" -ForegroundColor DarkGreen #Restart-Service "SQLAgent`$$instance" -WarningAction SilentlyContinue -Force $null = Enable-DbaAgHadr -SqlInstance $sqlinstance -Confirm:$false -Force -Restart-Service "SQLAgent`$$instance" -WarningAction SilentlyContinue -Force do { Start-Sleep 1