<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>get aduser reports Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/get-aduser-reports/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/get-aduser-reports/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Tue, 11 Aug 2020 03:51:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Get Direct Reports in Active Directory Using Powershell (Recursive)</title>
		<link>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/</link>
					<comments>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Wed, 29 Jan 2020 07:39:03 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[get aduser reports]]></category>
		<category><![CDATA[Get Direct Reports in Active Directory Using Powershell (Recursive)]]></category>
		<category><![CDATA[get-aduser recursive manager]]></category>
		<category><![CDATA[powershell export direct reports to csv]]></category>
		<category><![CDATA[powershell get aduser direct reports recursive]]></category>
		<category><![CDATA[powershell get aduser subordinates]]></category>
		<category><![CDATA[powershell get all reports]]></category>
		<category><![CDATA[powershell get all users under a manager]]></category>
		<category><![CDATA[powershell get direct reports recursive]]></category>
		<category><![CDATA[powershell get org chart from active directory]]></category>
		<category><![CDATA[powershell list users with direct reports]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1960</guid>

					<description><![CDATA[<p>It might come in handy from time to time to drill down on a manager&#8217;s direct reports in Active Directory. A good use case is if a director or VP wants to send an email to all of their direct&#8230; <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/">Get Direct Reports in Active Directory Using Powershell (Recursive)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It might come in handy from time to time to drill down on a manager&#8217;s direct reports in Active Directory.  A good use case is if a director or VP wants to send an email to all of their direct reports, and the direct reports of those direct reports.  Another use case would be if you were doing an audit comparing your HR system to what is in Active Directory.  What ever the reason might be,  you can use this script to get direct reports in active directory using Powershell. Pretty neat!! </p>
<p><em>If you have any questions regarding the script, feel free to leave me a comment and I&#8217;ll do my best to get back to you.</em></p>
<h2>Get Direct Reports in Active Directory Using Powershell</h2>
<pre class="brush: powershell; title: ; notranslate">

Function Get-DirectReport {
#requires -Module ActiveDirectory

&lt;#
.SYNOPSIS
    This script will get a user's direct reports recursively from ActiveDirectory unless specified with the NoRecurse parameter.
    It also uses the user's EmployeeID attribute as a way to exclude service accounts and/or non standard accounts that are in the reporting structure.
 
.NOTES
    Name: Get-DirectReport
    Author: theSysadminChannel
    Version: 1.0
    DateCreated: 2020-Jan-28
 
.LINK
    https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive -   
 
.PARAMETER SamAccountName
    Specify the samaccountname (username) to see their direct reports.
 
.PARAMETER NoRecurse
    Using this option will not drill down further than one level.
 
.EXAMPLE
    Get-DirectReport username
 
.EXAMPLE
    Get-DirectReport -SamAccountName username -NoRecurse
 
.EXAMPLE
    &quot;username&quot; | Get-DirectReport
#&gt;

    [CmdletBinding()]
    param(
        [Parameter(
            Mandatory = $false,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true
        )]

        [string]  $SamAccountName,

        [switch]  $NoRecurse
    )

    BEGIN {}

    PROCESS {
        $UserAccount = Get-ADUser $SamAccountName -Properties DirectReports, DisplayName
        $UserAccount | select -ExpandProperty DirectReports | ForEach-Object {
            $User = Get-ADUser $_ -Properties DirectReports, DisplayName, Title, EmployeeID
            if ($null -ne $User.EmployeeID) {
                if (-not $NoRecurse) {
                    Get-DirectReport $User.SamAccountName
                }
                [PSCustomObject]@{
                    SamAccountName     = $User.SamAccountName
                    UserPrincipalName  = $User.UserPrincipalName
                    DisplayName        = $User.DisplayName
                    Manager            = $UserAccount.DisplayName
                }
            }
        }
    }

    END {}

}

</pre>
<p>&nbsp;</p>
<p>Like always I like to test out my scripts to ensure the content that I am publishing is legit for people to use so I created a sample org chart.  This is what that looks like.<br />
<a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png" target="_blank" rel="noopener noreferrer"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png" alt="Sample org chart" width="1072" height="315" class="aligncenter size-full wp-image-2005" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart.png 1072w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart-1024x301.png 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Sample-org-chart-768x226.png 768w" sizes="(max-width: 1072px) 100vw, 1072px" /></a></p>
<p>&nbsp;<br />
With the above already created in my lab let&#8217;s run <strong>Get-DirectReport -SamAccountName cio | Sort-Object samaccountname</strong> so we can quickly get an org chart for everyone under our CIO.  By default it does run recursively so I&#8217;ll also run the <strong>-NoRecurse parameter</strong> to only get the people that are reporting directly to the CIO.  </p>
<p>This is what the output looks like.</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png" alt="Get-DirectReport -samaccountname" width="1099" height="481" class="aligncenter size-full wp-image-1999" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname.png?v=1596953798 1099w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname-1024x448.png?v=1596953798 1024w, https://thesysadminchannel.com/wp-content/uploads/2020/08/Get-DirectReport-samaccountname-768x336.png?v=1596953798 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p>I&#8217;d love to hear your feedback and I hope you can use this in your environment if you ever need a quick org chart using Powershell.  As always be sure to check out our Youbtube Channel <a href="https://www.youtube.com/c/TheSysadminChannel" rel="noopener noreferrer" target="_blank">https://www.youtube.com/c/theSysadminChannel</a> or if you want more Powershell scripts or content, check out our <a href="https://thesysadminchannel.com/powershell/" rel="noopener noreferrer" target="_blank">Powershell Category</a>.  There is a lot of useful information on both links.</p>
<p>The post <a href="https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/">Get Direct Reports in Active Directory Using Powershell (Recursive)</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-direct-reports-in-active-directory-using-powershell-recursive/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1960</post-id>	</item>
	</channel>
</rss>
