Hi all,

I've written an AD search script and am having a strange problem with
returning the result count when ONE item is returned.

If one result is returned I get no value displayed for $results.count.
Anything greater than "one" returns the correct count.

Moreover, in order to return "one" result I need to use *-ge -1* in the
if/else statement. [see below]

Is this a known issue or can someone tell me what value is/should be
returned for a single result?

$results = $searcher.FindAll() | Sort-Object@{Expression={$_.Properties.sn}}
if ($results.count -ge -1)
{
# Format our results
cls
Write-Host "Results for $field = $value." $results.count "results found."
ForEach ($user in $results)
{
GetUserInfo `
$user.properties.sn `
$user.properties.givenname `
$user.properties.mail `
$user.properties.employeeid `
$user.properties.department `
$user.properties.telephonenumber `
$user.properties.wwwhomepage
}
}
else
{
cls
Write-Host "No results found. Try to broaden your search scope."
}

Regards,

Paul Noone

--
SharePoint Farm Admin/Developer
Infrastructure Team
CEO Sydney

p: (02) 9568 8461
f: (02) 9568 8483
e: paul.no...@syd.catholic.edu.au
w: http://www.ceosyd.catholic.edu.au/
_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to