none
The Answer + 1 RRS feed

  • Question

  • I know I'm a relative newbie, but this just cost me two hours of troubleshooting an application sync issue that didn't exist.  Can somebody please tell me why this is returning a count that's one higher than the actual number of users in the group?  I found my problem with a 40-something line VBS script, but this PowerShell command should have been able to do it in one line; or so I thought.

    (dsget group "CN=GroupName" -members").count

    Thanks for your help.


    • Edited by s31064 Wednesday, September 10, 2014 11:06 PM
    Wednesday, September 10, 2014 11:04 PM

Answers

  • The output from the command is returned as an array of strings (one per line).  The count property is a count of the number of lines returned, The command adds a additional blank line after the list of members.  That blank line is your +1 in the count.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by tommymaynard Wednesday, September 10, 2014 11:24 PM
    • Marked as answer by s31064 Wednesday, September 10, 2014 11:33 PM
    Wednesday, September 10, 2014 11:16 PM
    Moderator

All replies

  • The output from the command is returned as an array of strings (one per line).  The count property is a count of the number of lines returned, The command adds a additional blank line after the list of members.  That blank line is your +1 in the count.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by tommymaynard Wednesday, September 10, 2014 11:24 PM
    • Marked as answer by s31064 Wednesday, September 10, 2014 11:33 PM
    Wednesday, September 10, 2014 11:16 PM
    Moderator
  • Since all I was interested in was the actual count, I never saw the output and the blank line at the end. That makes perfect sense. Thanks for the quick response.
    Wednesday, September 10, 2014 11:33 PM