Forum Discussion

ADumith's avatar
ADumith
Iron Contributor
Apr 19, 2023
Solved

How to list the disabled accounts and in which groups they are.

Hello guys, I have the following script, my goal is to list all user accounts that are not enabled and in which group they are.   Get-ADUSer -SearchBase "DC=mydomain,DC=net" -Filter {enabled -eq ...
  • Andres-Bohren's avatar
    Andres-Bohren
    Apr 19, 2023

    ADumith elieelkarkafi 

     

    The Approach from elieelkarkafi  works fine.

     

    $DisabledUsers = Get-ADUser -Filter {(Enabled -eq $false)} -Properties MemberOf | Select-Object Name, MemberOf
    Foreach ($User in $DisabledUsers)
    {
    Write-Host "Username: $($User.Name)"
    Foreach ($Group in $user.MemberOf)
    {
    Write-Host "Group: $Group"
    }
    }

     

    Regards

    Andres

Resources