In a previous article we looked at group membership for accounts in Active Directory that you can pull using PowerShell. In this short article we will look at extracting certain information for a user account or for all users in Active Directory.

For all users, you can use the following script:

Get-ADUser -filter * -Properties * | Select-Object GiveName, Surname, SamAccountName, EmailAddress, LastLogonDate, PasswordLastSet, Enabled, PasswordExpired, LockedOut > C:\Users.csv

Here is what it looks like in PowerShell:

Powershell:- get properties of a user account/s in active directory.

If you want to do this for a specific user, you can use the following script:

Get-ADUser UserA -Properties * | Select-Object GiveName, Surname, SamAccountName, EmailAddress, LastLogonDate, PasswordLastSet, Enabled, PasswordExpired, LockedOut > C:\Users.csv

The above scripts will output the information to C:\users.csv.

If you want to display the information on screen for that user, you can use this script without the bracket >:

Get-ADUser UserA -Properties * | Select-Object GiveName, Surname, SamAccountName, EmailAddress, LastLogonDate, PasswordLastSet, Enabled, PasswordExpired, LockedOut

This is what the output in PowerShell will look like:

Powershell:- get properties of a user account/s in active directory.

Hope it helps

    wpChatIcon

    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading