locked
Getting list of all users and what groups they belong to RRS feed

  • Question

  • Hi,

    Trying to make a powershell script to list all users in AD, and what groups they belong to.

    First tried to make it to a csv file, and the resault was 

    Oracle  Microsoft.ActiveDirectory.Management.ADPropertyValueCollection

    Made it to a txt file, and resault was

    Oracle                                                                                                   {CN=ROLE-CITRIX-USER,OU=Applikasjoner,OU=Roller,...

    How to get it to list all the groups, not just 3-4 groups?

    Wednesday, January 4, 2017 8:38 AM

Answers

  • Get-Aduser -Filter * -Properties Givenname, Surname, Memberof| 
    	select Givenname, Surname, SamAccountname, @{n='MemberOf';e={$_.Memberof -join '|'}} |
    	Format-List


    \_(ツ)_/

    Wednesday, January 4, 2017 10:17 AM

All replies

  • You will need to post Oracle questions in an Oracle forum .


    \_(ツ)_/

    Wednesday, January 4, 2017 9:13 AM
  • This is not a Oracle question, just a user names Oracle...
    Wednesday, January 4, 2017 9:15 AM
  • What is a user names Oracle?  Your question makes no sense.  Without a code example there is no way to understand what you are trying to ask.

    To get users we would use Get-AdUser.  We would not use Oracle.  Oracle is a database system.  It has nothing to do with AD users.


    \_(ツ)_/

    Wednesday, January 4, 2017 9:21 AM
  • Use the Get-ADPrincipalGroupMembership cmdlet, as in this example:

    https://gallery.technet.microsoft.com/PowerShell-Get-All-Group-167a9ce7

    You probably need to pipe your output to ft.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, January 4, 2017 9:33 AM
  • The "code" i used was

    Get-Aduser -Filter * | select Givenname,Surname,SamAccountname,Memberof

    It returns the info, but the "memberof" part gets cut because the line seems to be to long

    Tried with format-table, format-list,format-wide, autosize and wrap without luck. Any tips?

    Wednesday, January 4, 2017 10:09 AM
  • Get-Aduser -Filter * -Properties Givenname, Surname, Memberof| 
    	select Givenname, Surname, SamAccountname, @{n='MemberOf';e={$_.Memberof -join '|'}} |
    	Format-List


    \_(ツ)_/

    Wednesday, January 4, 2017 10:17 AM
  • Start by reading the first post from the top of this forum.

    This forum is for scripting questions rather than script requests


    -- Bill Stewart [Bill_Stewart]

    Wednesday, January 4, 2017 4:53 PM
  • That worked like a wonder :)

    By any chance, is there a way to get just the group name, but the full distinguishedname?

    Thursday, January 5, 2017 7:21 AM
  • Just add it to the script.

    In effect you are asking for use to write a script for you one item at a time.  That is not the purpose of this forum.

    Start here: https://technet.microsoft.com/en-us/dd742419


    \_(ツ)_/

    Thursday, January 5, 2017 9:39 AM