Hi,
The -Filter parameter can get the enabled/disabled users for you.
$enabled = Get-ADUser -Filter {enabled -eq $true} -SearchBase ‘OU=Users,OU=NY,OU=USA,DC=theitbros,DC=com’
$disabled = Get-ADUser -Filter {enabled -eq $false} -SearchBase ‘OU=Users,OU=NY,OU=USA,DC=theitbros,DC=com’
Remove-ADGroupMember -identity "NY Users" -Members $disabled -Confirm:$false
Add-ADGroupMember -identity "NY Users" -Members $enabled
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.