Thanks Geoff. Unfortunately that gives the same incorrect output.
e.g.
domain\User1
domain\User76
Nil
Nil
Domain\User243
I only want to return Nil once for each collection where the False count = 0.
I made some changes and this is getting very close...but still doesn't output
Nil for empty sets.
I think this may be less of a PS problem and more of a me problem. :)
$returncheck = Check_User_In_ActiveDirectory $Tablename[1] $mydomaincnx
$falseCheck = $returncheck.Count
if($falseCheck -gt 0)
{
foreach($Check in $falseCheck)
{
Write-Output $MyUser.LoginName
}
$falseCheck = 0
}
if($falseCheck -eq 0)
{
Write-Output "Nil"
}
}
From: [email protected] [mailto:[email protected]] On Behalf Of
Jeffery Tsui
Sent: Wednesday, 13 July 2011 12:56 PM
To: ozMOSS
Subject: Re: PS count number of false items
try this
$count = 0
# Enumerate orphans
foreach($Check in $returncheck)
{
if($Check -eq $False)
{
Write-Output $MyUser.LoginName
}
else
{
$count += 1
}
}
if($count -eq 0)
{
Write-Output "Nil"
}
On Wed, Jul 13, 2011 at 12:17 PM, Paul Noone
<[email protected]<mailto:[email protected]>>
wrote:
Hi all,
I'm having some logic problems with my PS script.
I am retrieving an array of users from AD and then checking a Boolean condition.
If the count of False eq 0 then I want to write "Nil". How do I get a count of
the False items in $returncheck??
Can someone please put me out of my misery. :)
$siteCollUsers = $web.SiteUsers
foreach($MyUser in $siteCollUsers)
{
if(($MyUser.LoginName.ToLower() -ne "sharepoint\system") -and
($MyUser.LoginName.ToLower() -ne "nt authority\authenticated users") -and
($MyUser.LoginName.ToLower() -ne "nt authority\local service"))
{
$UserName = $MyUser.LoginName.ToLower()
$Tablename = $UserName.split("\")
$returncheck = Check_User_In_ActiveDirectory
$Tablename[1] $mydomaincnx
# Enumerate orphans
foreach($Check in $returncheck)
{
if($returncheck -eq $False)
{
Write-Output $MyUser.LoginName
}
elseif($returncheck.Count($False) -eq 0)
{
Write-Output "Nil"
}
else
{
# Do nothing
}
}
}
}
_______________________________________________
ozmoss mailing list
[email protected]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss