Windows Vista Forums

foo.count without formatting
  1. #1


    Brian Hoort Guest

    foo.count without formatting

    How can I get foo.count to return just the integer so I can perform
    arithmetic on the result?

    I'm trying to write a one-liner that will return the number of
    non-disabled users in our AD. So far I can do this by invoking a
    dsquery returning all users, piping that into a ".count -line", then
    doing another with the dsquery switch that only returns disabled
    accounts, then getting a ".count -line" on that -- that far I've gotten
    (albeit with formatted output). Then I just subtract the disabled
    count from the full and get my count -- but I can't do this because the
    object .count returns isn't just an int -- it's a big formatted text
    object.

    Any thoughts?




      My System SpecsSystem Spec

  2. #2


    Brandon Shell Guest

    Re: foo.count without formatting

    Can you post the code?

    I tried this and it worked as expected... of course I used a ls instead of
    AD object, but should be the same result.

    PS C:\> $foo = ls * -recurse
    PS C:\> $foo.count
    77070
    PS C:\> $foo.count + $foo.count
    154140
    PS C:\> $foo.count + $foo.count - ($foo.Count / 2)
    115605
    PS C:\>


    "Brian Hoort" <brian.hoort@gmail.com> wrote in message
    news:1168297135.721425.65500@11g2000cwr.googlegroups.com...
    > How can I get foo.count to return just the integer so I can perform
    > arithmetic on the result?
    >
    > I'm trying to write a one-liner that will return the number of
    > non-disabled users in our AD. So far I can do this by invoking a
    > dsquery returning all users, piping that into a ".count -line", then
    > doing another with the dsquery switch that only returns disabled
    > accounts, then getting a ".count -line" on that -- that far I've gotten
    > (albeit with formatted output). Then I just subtract the disabled
    > count from the full and get my count -- but I can't do this because the
    > object .count returns isn't just an int -- it's a big formatted text
    > object.
    >
    > Any thoughts?
    >




      My System SpecsSystem Spec

foo.count without formatting problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
KMS Count Not Increasing! SuperhoopMango Vista installation & setup 0 21 Aug 2009
Get-childitem count bug or not bug ? Personne PowerShell 2 01 Jun 2009
count IT STAFF PowerShell 7 16 Jul 2008
Count Thomas PowerShell 3 02 Mar 2007