Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find-DbaInstance - Fix regex for UDP Search #9072

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/Find-DbaInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ function Find-DbaInstance {
#endregion Connect to browser service and receive response

#region Parse Output
$Response | Select-String "(ServerName;(\w+);InstanceName;(\w+);IsClustered;(\w+);Version;(\d+\.\d+\.\d+\.\d+);(tcp;(\d+)){0,1})" -AllMatches | Select-Object -ExpandProperty Matches | ForEach-Object {
$Response | Select-String "(ServerName;([a-zA-Z0-9_-]+);InstanceName;(\w+);IsClustered;(\w+);Version;(\d+\.\d+\.\d+\.\d+);(tcp;(\d+)){0,1})" -AllMatches | Select-Object -ExpandProperty Matches | ForEach-Object {
$obj = New-Object Dataplat.Dbatools.Discovery.DbaBrowserReply -Property @{
MachineName = $computer.ComputerName
ComputerName = $_.Groups[2].Value
Expand Down Expand Up @@ -1083,4 +1083,4 @@ function Find-DbaInstance {
}
$steppablePipeline.End()
}
}
}
6 changes: 3 additions & 3 deletions tests/Find-DbaInstance.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
Context "Command finds SQL Server instances" {
BeforeAll {
if ($env:APPVEYOR) {
$results = Find-DbaInstance -ComputerName $script:instance3 -ScanType Browser, SqlConnect
$results = Find-DbaInstance -ComputerName $script:instance3 -ScanType Browser, SqlConnect | Select-Object -First 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this be filtering on the actual $instance3 database service and not randomly picking whatever comes first in the list.

If we do that then the whole if/else block can be removed because it would match no matter the environment.

} else {
$results = Find-DbaInstance -ComputerName $TestServer -ScanType Browser, SqlConnect
$results = Find-DbaInstance -ComputerName $TestServer -ScanType Browser, SqlConnect | Select-Object -First 1
}
}
It "Returns an object type of [Dataplat.Dbatools.Discovery.DbaInstanceReport]" {
Expand All @@ -42,4 +42,4 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
$results.SqlConnected | Should -Be $true
wsmelton marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
Loading