How to Get and Set properties of the Active Directory user using PowerShell

How to Get and Set properties of the Active Directory user using PowerShell

In this article, we will discuss how to get and set properties of an Active Directory user using PowerShell.


Here’s how to get User Properties

To get user properties from Active Directory, Get-ADUser cmdlet can be used. Here is an example of how to retrieve the email address of a user:



  1. Get-ADUser -Identity "TechNoob" -Properties EmailAddress | Select-Object EmailAddress



  • In this example, we use the Get-ADUser cmdlet to retrieve the user object for the user "TechNoob". 
  • The -Properties parameter is used to specify the property we want to retrieve, which in this case is the EmailAddress property. 
  • We then channel the output to the Select-Object cmdlet to only display the EmailAddress property.



Here’s how to set User Properties


To set user properties in Active Directory, Set-ADUser cmdlet can be used. Here is an example of how to set the description of a user:



  1. Set-ADUser -Identity "TechNoob" -Description "New User Description"


In this example, we use the Set-ADUser cmdlet to set the description property for the user "TechNoob" to "New User Description".


Note that some properties, such as the samAccountName, cannot be changed once the user object has been created. Also, some properties require special permissions to modify.