'scuse my ignorance...
I use @($var).Count so I can get a count even if $var contains 1 "item".
When my search returns nothing why does my array contain one item?
i.e.
PS C:\Windows\system32> $Groups = $null
Import-Module -Name "activedirectory"
$search = "aaaarggg"
$searchPat = `"*"` + $search + `"*"`
$Groups = Get-ADGroup -Filter {(name -like $searchPat)}
if ($Groups -eq $null) {
"No matches"
@($Groups).Count
}
else {
"Matches"
@($Groups).Count
}
No matches
1