Home » PowerShell » Get AdUsers: Format Table Output Formatting

Get AdUsers: Format Table Output Formatting

The Format-Table (FT) cmdlet in PowerShell formats the output to the table. To format a list of adusers in the table, use the Get-AdUser cmdlet to get adusers and output to Format-Table for output formatting with the selected properties for the aduser object.

In this article, we will discuss how to get adusers formatting in the table using the Format-Table cmdlet.

Get AdUser Format Table Formatting

Use the Get-AdUser cmdlet in PowerShell to get one or more users from the active directory and pipe the aduser objects to the Format-Table to apply output formatting.

Get-AdUser -Filter * | Format-Table Name, DistinguishedName

In the above PowerShell script, the Get-AdUser gets adusers from the active directory and passes it to Format-Table to output it as a table with the selected properties like Name and DistinguishedName.

The output of the above PowerShell script to list adusers in table format is:

Get AdUser - Format Table output
Get AdUser – Format Table output

Format List of AdUsers with Format-Table

To format the list of adusers with the Format-Table cmdlet, use the Get-AdUser to get adusers and pipe them to the Format-Table cmdlet.

Get-AdUser -Filter * | Format-Table Name, DistinguishedName -AutoSize

In the above PowerShell script, the Get-Aduser uses the Filter * parameter to get a list of adusers and passes it to the Format-Table to display Name and aduser DistinguishedName in table format. The Autosize parameter adjusts the column widths.

The output of the above script to format a list of adusers using the Format-Table (FT) is:

PS C:\> Get-AdUser -Filter * | Format-Table Name, DistinguishedName -AutoSize

Name          DistinguishedName
----          -----------------

Guest         CN=Guest,CN=Users,DC=SHELLPRO,DC=LOCAL
krbtgt        CN=krbtgt,CN=Users,DC=SHELLPRO,DC=LOCAL
Tom Smith     CN=Tom Smith,OU=SALES,DC=SHELLPRO,DC=LOCAL
Erick Jones   CN=Erick Jones,OU=HR,DC=SHELLPRO,DC=LOCAL
Gary Willy    CN=Gary Willy,OU=HR,DC=SHELLPRO,DC=LOCAL
Chris Dore    CN=Chris Dore,OU=SALES,DC=SHELLPRO,DC=LOCAL
adam          CN=adam,CN=Users,DC=SHELLPRO,DC=LOCAL
nathan        CN=nathan,CN=Users,DC=SHELLPRO,DC=LOCAL
Don           CN=Don,CN=Users,DC=SHELLPRO,DC=LOCAL
Esh Deol      CN=Esh Deol,OU=HR,DC=SHELLPRO,DC=LOCAL
Tira Elsa     CN=Tira Elsa,OU=HR,DC=SHELLPRO,DC=LOCAL
Aron Seth     CN=Aron Seth,OU=HR,DC=SHELLPRO,DC=LOCAL
Dave NewHouse CN=Dave NewHouse,OU=SHELLUSERS,DC=SHELLPRO,DC=LOCAL
Harsh Dev     CN=Harsh Dev,OU=HR,OU=SHELLUSERS,DC=SHELLPRO,DC=LOCAL
Netya Xu      CN=Netya Xu,OU=FINANCE,OU=SHELLUSERS,DC=SHELLPRO,DC=LOCAL


PS C:\>

Conclusion

I hope the above article on how to format a list of adusers in table output using the Format-Table is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.