Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Zero did not appear / Where is my scalar value - zero ?

Reply
 
Old 08-12-2009   #1 (permalink)
IT Staff


 
 

Zero did not appear / Where is my scalar value - zero ?

i have some security groups with NO membership.

$count = get-qadgroupmember <grps>
$count looks to be empty.

But i want the $count to display 0



My System SpecsSystem Spec
Old 08-12-2009   #2 (permalink)
Alex K. Angelopoulos


 
 

Re: Zero did not appear / Where is my scalar value - zero ?

"IT Staff" <jkklim@xxxxxx> wrote in message
news:#0ADi$xGKHA.5956@xxxxxx
Quote:

> i have some security groups with NO membership.
>
> $count = get-qadgroupmember <grps>
> $count looks to be empty.
>
> But i want the $count to display 0
>
This is possible to do; you need to tell PowerShell to give you the results
as an array, even if the array has zero or only one member. Do this:

$members = @(get-qadgroupmember <grps>)

Note that I call this $members, not count - get-qadgroupmember returns
member objects, not a count of members. In any case, if you then check

$members.Count

you'll have the count of members from <grps>.

My System SpecsSystem Spec
Old 08-12-2009   #3 (permalink)
Shay Levy [MVP]


 
 

Re: Zero did not appear / Where is my scalar value - zero ?

Hi IT,


You need to force the rsult to an array so you'll have a count property,
scalas dont have count:


(get-qadgroupmember <grps>).count


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



IS> i have some security groups with NO membership.
IS>
IS> $count = get-qadgroupmember <grps>
IS> $count looks to be empty.
IS> But i want the $count to display 0
IS>


My System SpecsSystem Spec
Old 08-12-2009   #4 (permalink)
Shay Levy [MVP]


 
 

Re: Zero did not appear / Where is my scalar value - zero ?

I had a typo, should be:

@(get-qadgroupmember <grps>).count


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



SL> Hi IT,
SL>
SL> You need to force the rsult to an array so you'll have a count
SL> property, scalas dont have count:
SL>
SL> (get-qadgroupmember <grps>).count
SL>
SL> ---
SL> Shay Levy
SL> Windows PowerShell MVP
SL> http://blogs.microsoft.co.il/blogs/ScriptFanatic
SL> PowerShell Toolbar: http://tinyurl.com/PSToolbar
IS>> i have some security groups with NO membership.
IS>>
IS>> $count = get-qadgroupmember <grps>
IS>> $count looks to be empty.
IS>> But i want the $count to display 0


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Execute Scalar Stored Procedures in Entity Framework .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46