Forum Discussion
ADumith
Apr 19, 2023Iron Contributor
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 ...
- Apr 19, 2023
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
ADumith
Apr 20, 2023Iron Contributor
Thank you Andres,
How can I export that into a Excel file?
Thank you in advance.
How can I export that into a Excel file?
Thank you in advance.
Apr 20, 2023
Export-CSV -Path "C:\DisabledUsers.csv" -NoTypeInformation