No announcement yet.

dsget computer -memberof Help

  • Filter
  • Time
  • Show
Clear All
new posts

  • dsget computer -memberof Help

    Hello all,

    I am stuck and I was wondering if any of you experts could help.
    I need ti get the member of information of a computer from AD.
    I have the following:
    dsquery computer -name hostname | dsget computer -memberof

    The command works fine but it displays too much information for what I need. I just want the immediate member of name. When I run that command it gives me the CN,OU,DC, etc. Is there any way that I can filter the output to only show the CN which is the effective name of groups computer is a member of. I don't need to know the OU or any other information fields.

    I spent all week searching, googling, and I found nothing on being able to filter the memberof results to just display the CN info.

    Any suggestions or help will be appreciated


  • #2
    Re: dsget computer -memberof Help

    Would this do:
    for /f "tokens=2 delims==," %a in ('dsquery compu
    ter -name hostname ^| dsget computer -memberof') do echo %a
    Remember to change "%a" to "%%a" if you're using it in a batch file.


    • #3
      Re: dsget computer -memberof Help

      Yes, sir, thank you so much, it works. I thought I could use a for command just could not get the right fomat, I suck at for commands . Any way I can get the output to come out in a list instead of one line each. I am making a small Visual basic program and want to display the members of group


      • #4
        Re: dsget computer -memberof Help

        What sort of list? Group names separated by commas? The names may include spaces, so should they be in quotes?


        • #5
          Re: dsget computer -memberof Help

          Well when I run the command it displays the output as command line c:\users\myusername> echo namememberof1

          c:\users\myusername> echo namememberof2

          c:\users\myusername> echo namememberof3

          ETC. ETC. all the way through the members of list.
          I was wondering if there was anyway where it could just spit it sort of like in a list, for example

          then I could out pipe that out put to a msg console display.

          I'm basically making a small help desk tool for our support team that gives basic user and computer information for faster reference instead of having them look up the info in active directory

          if there's isn't any way, that's fine Ser Olmy, you've been more than helpful, appreciate it. thanks


          • #6
            Re: dsget computer -memberof Help

            Just put it in a batch file:
            @echo off
            for /f "tokens=2 delims==," %%a in ('dsquery computer -name %1 ^| dsget computer -memberof') do echo "%%a"
            Call the file with the computer name as an argument:

            nameofbatchfile hostname
            Last edited by Ser Olmy; 29th January 2014, 23:10. Reason: Typo


            • #7
              Re: dsget computer -memberof Help

              Yes, I thought about that on the way home from work. Thanks for all your help. . you are gangster IT