Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting top down org view with PowerShell

9 views
Skip to first unread message

Steven Presley

unread,
Jan 5, 2010, 10:55:02 AM1/5/10
to

Does anyone have any quick code samples that can return a list of all
reports to a manager and below? I'm looking to make some distribution
groups based on a manager and all their reports (direct and otherwise).

Thanks!

Chris Dent

unread,
Jan 5, 2010, 11:00:33 AM1/5/10
to

If you're using LDAP Filters using LDAP_MATCHING_RULE_IN_CHAIN should
return all reports of a given manager. For example:

(manager:1.2.840.113556.1.4.1941:=CN=Manager,OU=Somewhere,DC=domain,DC=com)


Then you only have to specify the highest level manager.

If you're using Quest's CmdLets that can become:

Get-QADUser -LdapFilter
"(manager:1.2.840.113556.1.4.1941:=CN=Manager,OU=Somewhere,DC=domain,DC=com)"

Any use?

Chris

Steven Presley

unread,
Jan 5, 2010, 11:36:43 AM1/5/10
to
This does indeed seem to work..thanks a ton!

Thanks!

Cameron

unread,
Jan 6, 2010, 2:24:01 PM1/6/10
to
Well if you are using PowerShell v2 RTM on Windows 2008R2 or Windows 7 then
this works great:

get-aduser -Properties directreports -filter * | ?{$_.directreports.count
-ne 0} | select name, directreports | sort name | ft
--
cameron


"Steven Presley" wrote:

> .
>

Steven Presley

unread,
Jan 7, 2010, 10:22:55 AM1/7/10
to
I'll give that a whirl as well..thanks for the suggestion...I'll have to
see which is more efficient (speedy).

Cameron

unread,
Jan 7, 2010, 3:13:02 PM1/7/10
to
The following one-liner outputs like this:

Manager1
------------------------
Employee1
Employee2

Manager2
------------------------
Employee3
Employee4

Get-ADUser -filter * -Properties samaccountname, displayname, manager |
group {if($_.manager -ne $null){(Get-ADObject $_.manager -Properties
displayname).displayname}else{"UNKNOWN"}} | sort name | %{$_.Name;
"-------------------"; ($_.Group | %{if($_.displayname -ne
$null){"`t$($_.displayname)"}else{"`t$($_.samaccountname)"}}); "`n"}

--
Cameron


"Steven Presley" wrote:

> .
>

0 new messages