Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

(help needed) How to list out the users from an OU

$
0
0

I’ve gone in circles on this an confused myself, so I need sanity. I’ve got users in various departments: “OU=Departments,DC=mydomain,DC=local”

Under that, the groups are like Treasurer, Engineer, Building and Grounds, etc., and the groups contain AD users.

Here’s the command I arrived at to list off my groups in the Departments OU:

get-adobject -filter 'ObjectClass -eq "organizationalUnit"' -SearchBase "DC=mydomain,DC=Local" | where { $_.distinguishedname -like "*Departments*"} | select name,distinguishedname | sort name 

This works fine, shows me all my departments like I want to see them. From there, though, I’ll be damned if I can go the next step and pull the users out of the departments. Did I start off on the wrong foot, and that’s why I’m failing? I won’t even try to list off all the crap I’ve tried–I’m very confused and lost track, just stabbing in the dark eventually. Your help is much appreciated.

(Edit for privacy)

submitted by /u/motsanciens
[link] [comments]

The post (help needed) How to list out the users from an OU appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles