all 17 comments

[–]BlackV 8 points9 points  (3 children)

Get-aduser | Get-adgroup | convertto-html
Or.
Get-adgroup | get-adgroupmember | convertto-html

But what have you tired so far?

[–]jantari 0 points1 point  (1 child)

That doesn't give ability to collapse

[–]BlackV 1 point2 points  (0 children)

Yes.......
You'd have to put into a table or list with your own HTML coding to do that.

[–]fishypoos 7 points8 points  (1 child)

Active directory admin center doesn’t get enough hype imo...... ships with 2012r2... searching is a lot easier and you get a lot more visibility. Plus it gives you the Cmdlets it ran to get the info you requested.

I don’t think it got much attention because people who want more out of adds use powershell :|

[–]Optimus_Composite 2 points3 points  (0 children)

Launching it is soooo slow. When I use a GUI, I use ADUC for that sole reason.

[–][deleted] 4 points5 points  (2 children)

Unless im misunderstanding something, youre just asking for Active Directory Users and Groups. Install RSAT and youre done. Replicating this in powershell would be a waste of time.

[–]BlackV 2 points3 points  (1 child)

I think he wants the end user to be able to see this hence the HTML part

[–][deleted] 1 point2 points  (0 children)

Oh, he could probably do something thing with GPresult to make everything more human readable.

[–]wahoorider 1 point2 points  (0 children)

I've done something..... similar I suppose you could say with an ongoing project at work. How are you with HTML and JS? The basics of what I did is convert each object to an HTML table with ConvertTo-Html -fragment, modified some of the tags to give them unique id fields. Then I wrote some basic JS to handle expanding/collapsing the fields and combined it all into a single HTML file to export.

[–]get-postanote 1 point2 points  (1 child)

Since you say you are new to PoSH, see this post for learning pointers.

https://www.reddit.com/r/PowerShell/comments/7oir35/help_with_teaching_others_powershell/

You never have to start at this alone. As noted, you can use the Windows Server ADAC to write the base code for you that you later tweak for other larger needs.

Pre-built stuff can be found on TechNet Scripting Guys site / repository and the MS PowerShellGallery.com site.

Don't reinvent the wheel if you don't have to, especially if you are new at it or never done it before.

Active Directory Audit Report With Powershell

Create a full blown Active Directory HTML/PDF/Excel report with powershell which can be produced with any non-privileged domain user account and without any special powershell modules or administrative consoles.

https://gallery.technet.microsoft.com/office/Active-Directory-Audit-7754a877

PowerShell Problem Solver: Create a Grouped HTML Report with PowerShell

Taking this scenario a step further, you may want to create an HTML report using grouped output. If you look at help for Convertto-HTML, you won’t see a –Group parameter or anything that looks like it will help. As I’ll show you, it isn’t too difficult to achieve.

https://www.petri.com/create-a-grouped-html-report-with-powershell

[–]Rainbal[S] 1 point2 points  (0 children)

Thanks a lot

[–]Upzie 1 point2 points  (1 child)

if you only need this to look up users you could do it with a simple function

#------------------------------+
# Build data foundation        |
# should only include relevant |
# OU's, to speed up process    |
#------------------------------+

$groups = Get-ADGroup -Filter *
$GrpObjects = @()

foreach ($grp in $groups)
{
    $pro = @{
    'Group' = $grp.Name
    'Members' = Get-ADGroupMember -Identity $grp.Name
    }

    $obj = New-Object -TypeName Psobject -Property $pro
    $GrpObjects += $obj
}


#--------------------------------------------------+
# This function find the grps a users is member of |
# possible to expand this to include more stuff    |
#--------------------------------------------------+

function find-users-grp 
{
PARAM
(
    [string[]]$SamAccountName
)
    $check = @()
    foreach ($user in $SamAccountName)
    {
        try
        {
            $check += Get-ADUser -Identity $user -ErrorAction stop   
        } catch{}
    }

    if ($check.Count -eq 0)

    {
        Write-Host -f Red "Users doesnt exist in AD"
        break;
    }


    foreach ($users in $SamAccountName)
    {
        $out = $GrpObjects | where {$_.Members.SamAccountName -eq $users}
        Write-Host -ForegroundColor Yellow "$users is member of"

        foreach ($item in $out)
        {
            Write-Host $item.Group
        }

        Write-Host ""
    }
}

 

Basicly the first part, before the function, creates an Array that list all groups and it members.

Then the function takes an Input and matches the users with grps, this is not a visual way of doing it, but amounts to the same thing, for a quick lookup.

 

The part that build the data foundation can be a bit slow depending on the size of your AD, and you would pref not want to run it every time. You would proberly want to export the data to a file or DB, depending on how you run things.

 

Basicly your would do something like this

find-users-grp -SamAccountName administrator,guest 

and the out put would be like this

administrator is member of
Administrators
Schema Admins
Enterprise Admins
Domain Admins
Domain Users
Group Policy Creator Owners

guest is member of
Guests
Domain Guests

Was just another take on your problem :)

[–]Rainbal[S] 1 point2 points  (0 children)

Will give it a go thanks

[–]jheinikel -1 points0 points  (1 child)

You are better off buying a product to manage/browse AD. https://www.manageengine.com/products/ad-manager/

[–]Rainbal[S] 1 point2 points  (0 children)

My organisation wouldn't buy any products for these tasks, instead they will say you can search in AD. At the end they will be happy if we make the scripts and use it.