Use Powershell to set the hidefromaddresslist attribute on Active Directory user accounts

If you have ever had the need to set the “hidefromaddresslist” or any other attribute on Active Directory accounts, powershell is definitely your friend.  The Active Directory powershell commandlets from Quest make Powershell even more powerful and useful working with Active Directory.  Below is an example of code that one can use to set the hidefromaddresslist attribute on a list of AD accounts found in a CSV file.

This makes things much easier than having to search for AD accounts one by one and then manually set the attribute on each user account.  This script can be easily modified to set whatever attribute you are needing set by simply changing the attribute name below.


Always use extreme caution when mass altering active directory attributes using a script.  If you accidentally set something improperly, you could really damage your environment.  ALWAYS test your script in a test environment before implementing in production.

  • Download the Quest Active Roles commandlets to extend your powershell commandlets functionaility:  https://www.quest.com/powershell/activeroles-server.aspx
  • Prepare a CSV file.  Make sure in the first row of the CSV file to place “username” first, then following down the column with your usernames.
Import-Csv c:\\pathtoyourcsvfile | foreach {
    #adds the username value from the csv to a variable called $user
    $user = $_.username
    #Reads the user information for AD for each user in the csv and gets the group membership for that user
    Set-QADUser $user -ObjectAttributes @{msExchHideFromAddressLists= 'TRUE'}   

If you need to connect to a different domain other than the one your workstation is joined to, use the Connect-QADService commandlet:

Connect-QADService yourdomain.com -Credential ( Get-Credential DOMAIN\\user )




Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.