How to retrieve only enabled users from the Active Directory

.. or a little bit shorter this way:

Get-ADUser -Filter 'enabled -eq $true' -Properties mail | 
    Select-Object -Property Name,samaccountname,mail

Besides this I would recommend to use a -SearchBase. That's less stressful for the AD. ;-)


Important to know for both commands: You must work with an elevated powershell process. Otherwise the result may not be complete.


Get-ADUser -Filter * -Properties mail | Where { $_.Enabled -eq $True} | Select Name,samaccountname,mail

That will get all enabled users in your target domain that are enabled and display the name, username, and mail properties