From c984b2e14f9586def9be59b3a7a49a6848f392ff Mon Sep 17 00:00:00 2001 From: uncletimmy3 <34276679+uncletimmy3@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:17:05 +0500 Subject: [PATCH] Find-DbaInstance - Fix regex for UDP Search (#9072) --- public/Find-DbaInstance.ps1 | 4 ++-- tests/Find-DbaInstance.Tests.ps1 | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/Find-DbaInstance.ps1 b/public/Find-DbaInstance.ps1 index bf1d4a6dec..8274cd729e 100644 --- a/public/Find-DbaInstance.ps1 +++ b/public/Find-DbaInstance.ps1 @@ -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 @@ -1083,4 +1083,4 @@ function Find-DbaInstance { } $steppablePipeline.End() } -} \ No newline at end of file +} diff --git a/tests/Find-DbaInstance.Tests.ps1 b/tests/Find-DbaInstance.Tests.ps1 index a877984620..2903da74a3 100644 --- a/tests/Find-DbaInstance.Tests.ps1 +++ b/tests/Find-DbaInstance.Tests.ps1 @@ -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 } 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]" { @@ -42,4 +42,4 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { $results.SqlConnected | Should -Be $true } } -} \ No newline at end of file +}