Skip to content

Commit fd72a47

Browse files
committed
(#66) Fixes Get-CCMComputer Matching Names
Unless we intended to provide regex-matching functionality here (which isn't obvious from the help), this fixes the ability to return multiple computers with a single name (or even random regex query).
1 parent 2b62e01 commit fd72a47

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Public/Get-CCMComputer.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function Get-CCMComputer {
4949
switch ($PSCmdlet.ParameterSetName) {
5050
"Computer" {
5151
foreach ($c in $computer) {
52-
[pscustomobject]$records.result | Where-Object { $_.name -match "$c" }
52+
[pscustomobject]$records.result | Where-Object { $_.name -eq $c }
5353
}
5454
}
5555
"Id" {

src/Tests/Public/Get-CCMComputer.Tests.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Describe "Get-CCMComputer" {
1111
$Uri.AbsolutePath -eq "/api/services/app/Computers/GetAll"
1212
} {
1313
@{
14-
result = 1..9 | ForEach-Object {
14+
result = 1..20 | ForEach-Object {
1515
[PSCustomObject]@{
1616
name = "Computer $_"
1717
}
@@ -41,7 +41,7 @@ Describe "Get-CCMComputer" {
4141
}
4242

4343
It "Returns All Computers" {
44-
$Result | Should -HaveCount 9
44+
$Result | Should -HaveCount 20
4545
}
4646
}
4747

@@ -68,9 +68,7 @@ Describe "Get-CCMComputer" {
6868
Context "Getting computers by Name" {
6969
BeforeAll {
7070
$TestParams = @{
71-
# This test fails when Computer 1 and Computer 10 are both selected, due to the naive match
72-
Computer = 1..9 | Get-Random -Count (Get-Random -Minimum 1 -Maximum 9) | ForEach-Object { "Computer $($_)" }
73-
# Computer = 1..10 | Get-Random -Count (Get-Random -Minimum 1 -Maximum 10) | ForEach-Object { "Computer $($_)" }
71+
Computer = 1..10 | Get-Random -Count (Get-Random -Minimum 1 -Maximum 10) | ForEach-Object { "Computer $($_)" }
7472
}
7573
$Result = Get-CCMComputer @TestParams
7674
}

0 commit comments

Comments
 (0)