# Remove Disabled Users From a Managers Direct Report

**URL:** <https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134>\
**Category:** PowerShell Help\
**Created:** [October 23, 2020, 4:25am UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134 "2020-10-23T04:25:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuzbuster83](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@fuzbuster83](https://forums.powershell.org/u/fuzbuster83)\
**Post date:** [October 23, 2020, 4:25am UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134/1 "2020-10-23T04:25:46Z")

</div>

When we disable users in our AD, they are moved to an Archive OU. When you view their managers AD properties, the disabled users still appear and there is no indication that the users is disabled.

Is there a way to have Powershell go and find these situations? Either find a manager who that has users that are disabled, or to find a disabled user whose manager is enabled?

If some functions exists, I’m hoping to run this every month to keep the AD a little cleaner.

---

<div class="post-metadata">

**Author:** ![dhrubbharali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dhrubbharali/32/47_2.png) [@dhrubbharali](https://forums.powershell.org/u/dhrubbharali)\
**Post date:** [October 25, 2020, 6:06am UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134/2 "2020-10-25T06:06:40Z")

</div>

Not sure if the below script help your requirement.

### This will fetch the disabled user

$b=get-aduser -filter {(Enabled -eq $False)} -Properties \* |select Name,@{n=“Manager”;e={(get-aduser $\_.manager).name}}  
$c=$b.manager  
foreach($d in $c){

#### This will show the Manager who is enabled if the user is disabled

get-aduser -Identity $d -Properties Enabled|where {$\_.Enabled -eq $true}|select Name,Enabled

}

If this helps dive into other scripts in my [website](http://www.powershellguru.com).

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [October 26, 2020, 9:15am UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134/3 "2020-10-26T09:15:33Z")

</div>

What is generating the report? Is there an LDAP filter? The simplest solution would be to filter out the Archive OU from the reporting. Next, why not remove the managers from all disabled accounts and going forward remove the manager when disabling?

---

<div class="post-metadata">

**Author:** ![fuzbuster83](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@fuzbuster83](https://forums.powershell.org/u/fuzbuster83)\
**Post date:** [October 27, 2020, 5:14am UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134/4 "2020-10-27T05:14:48Z")

</div>

I will try the script and see if that will work. If it doesn’t net what we want, we will just manually remove the managers from all disabled users and going forward remove the manager as part of the termination process.

&nbsp;

If the script does work I will report back.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/remove-disabled-users-from-a-managers-direct-report/15134/5 "2024-05-16T20:28:40Z")

</div>

Closed on May 16, 2024, 8:28pm UTC


