Hi Jeff
To find out what is returned in $returnCheck, could you try:
write-host $returnCheck.GetType()
Comment out the rest of the script or type in each line into the console. If
$returnCheck returns a collection, then what is in one element of the
collection?
eg.
write-host $returnCheck[0].GetType()
write-host $returnCheck[0] | Get-member
Another thought: Does
get-help Check_User_In_Active_Directory
give you anything useful?
From: [email protected] [mailto:[email protected]] On Behalf Of
Paul Noone
Sent: Wednesday, 13 July 2011 2:25 PM
To: [email protected]; ozMOSS
Subject: RE: PS count number of false items
Hi Jeff,
Beats me. It seems to be an internal command but I can't find any doco for it.
>From what I can tell it returns a user table where [1] represents the Enabled
>flag.
$returncheck = Check_User_In_ActiveDirectory $Tablename[1] $mydomaincnx
From: [email protected] [mailto:[email protected]] On Behalf Of
Jeffery Tsui
Sent: Wednesday, 13 July 2011 2:09 PM
To: ozMOSS
Subject: Re: PS count number of false items
what is returned from Check_User_In_ActiveDirectory? a collection of users or
collection of true/false result?
"I only want to return Nil once for each collection where the False count = 0."
<-- which collection is this? siteCollUsers or returncheck ?
On Wed, Jul 13, 2011 at 1:52 PM, Paul Noone
<[email protected]<mailto:[email protected]>>
wrote:
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]>
[mailto:[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]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
--
_______________________________________________________________________________
Notice from Melbourne Business School Ltd
The information contained in this e-mail is confidential, and is intended for
the named person's use only. It may contain proprietary or legally privileged
information. If you have received this email in error, please notify the
sender and delete it immediately. You must not, directly or indirectly, use,
disclose, distribute, print, or copy any part of this message if you are not
the intended recipient
Internet communications are not secure. You should scan this message and any
attachments for viruses. Melbourne Business School does not accept any
liability for loss or damage which may result from receipt of this message or
any attachments.
______________________________________________________________________________
_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss