Command Line...

Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
Alright, so I put the command line and scripting off...

As an exercise in the command line I was trying to write something that would return all of the users who are a member of a specific group. I would have thought dsquery could do this but so far no luck.

Any ideas?
-Daniel

Comments

  • royalroyal Member Posts: 3,352 ■■■■□□□□□□
    dsget group "CN=GroupName,OU=NameofOU,DC=domain,DC=com" -members -expand

    or if you don't want to bother with the DN

    dsquery group domainroot -name group* | dsget group -members -expand
    “For success, attitude is equally as important as ability.” - Harry F. Banks
  • slinuxuzerslinuxuzer Member Posts: 665 ■■■■□□□□□□
    Royal, had I not had to spend ten minutes researching I would have beat you to it.
    Muahahahahahhaa

    Oh yea, you can use Ldp to get the Dn
  • EssendonEssendon Member Posts: 4,546 ■■■■■■■■■■

    Royal, had I not had to spend ten minutes researching I would have beat you to it.
    Muahahahahahhaa

    Oh yea, you can use Ldp to get the Dn


    royal Posted: Wed May 14, 2008 11:27 pm Post subject:


    dsget group "CN=GroupName,OU=NameofOU,DC=domain,DC=com" -members -expand

    or if you don't want to bother with the DN

    dsquery group domainroot -name group* | dsget group -members -expand

    Royal knows his stuff inside out, there's almost no beating him at anything even related to W2K3. Whenever he posts anything, everyone stands to learn something.
    NSX, NSX, more NSX..

    Blog >> http://virtual10.com
  • Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
    Man that was quick!
    -Daniel
  • Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
    Didn't work, anyone see anything I missed?

    C:\Documents and Settings\Administrator>dsget group "CN=Administrators,OU=London,DC=ad,DC=
    kahn,DC=com" -members -expand

    dsget failed:Directory object not found.
    type dsget /? for help.
    -Daniel
  • doom969doom969 Member Posts: 304
    Is your domain named ad.kahn.com or is that the name of your dc ?

    If your domain name is only kahn,com the command should be

    dsget group "CN=Administrators,OU=London,DC=kahn,DC=com" -members -expand

    also, I beleive the dn is case sensitive.
    Doom969
    __________________________________________________________
    MCP (282 - 270 - 284 - 290 - 291 - 293 - 294 - 298 - 299 - 350)
    MCTS (351 - 620 - 622 - 647 - 649 - 671)
    MCSA / S / M - MCSE / S
    MCITP (EST - EA ) - MCT
    A+ - IBM - SBSS2K3 - CISCO_SMB
    CompTIA : A+
  • sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    Do you have a domain group called Administrators in the London OU? Your not looking for local Administrators are you?
    All things are possible, only believe.
  • Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
    Oh yeah! You're right, nothing in London but a user account. I misunderstood how it worked.

    So let me throw out a scenario.

    You manager walks in and IT audit wants to know how many people are in group XYZ in every OU in the domain. He wants this in Excel format... is there a way to save this as a text file? CSV?
    -Daniel
  • dynamikdynamik Banned Posts: 12,312 ■■■■■■■■■□
    C:\Documents and Settings\Administrator>dsget group "CN=Administrators,OU=London,DC=ad,DC=kahn,DC=com" -members -expand > c:\dsget.txt

    I just copied that from above. Be sure to use the correct string ;)

    Also, that works with pretty much any command line utility that generates output text. i.e. netstat -a > c:\netstat.txt
  • Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
    80's guy from Futurama: awesome to the max!
    -Daniel
  • doom969doom969 Member Posts: 304
    Daniel333 wrote:
    Oh yeah! You're right, nothing in London but a user account. I misunderstood how it worked.

    So let me throw out a scenario.

    You manager walks in and IT audit wants to know how many people are in group XYZ in every OU in the domain. He wants this in Excel format... is there a way to save this as a text file? CSV?

    I beleive the correct answer to that os to use CSVDE, wich I remember is in the mspress as a tool you should know about.

    http://technet2.microsoft.com/windowsserver/en/library/1050686f-3464-41af-b7e4-016ab0c4db261033.mspx?mfr=true
    Doom969
    __________________________________________________________
    MCP (282 - 270 - 284 - 290 - 291 - 293 - 294 - 298 - 299 - 350)
    MCTS (351 - 620 - 622 - 647 - 649 - 671)
    MCSA / S / M - MCSE / S
    MCITP (EST - EA ) - MCT
    A+ - IBM - SBSS2K3 - CISCO_SMB
    CompTIA : A+
Sign In or Register to comment.