EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell Format Table
 

PowerShell Format Table

Priya Pedamkar
Article byPriya Pedamkar

Updated March 24, 2023

PowerShell Format Table

 

 

Introduction to PowerShell Format Table

We have many commands to see different types of outputs, but what if we need the output in a certain format that is more readable and understandable? So for that, we can use Powershell Format-Table, This commands display output in the format that we need. Let’s take one example, suppose we are going to display specific columns names like name, date, and CPU, etc, then we will use the command Format-Table. A normal command like Get-process will display all the columns which you may not require, but Get-process along with command Format-Table command will give only specific columns that we are needed. So with the help of Format-Table command, we can arrange and show only those columns which are necessary to see. This command is very useful where we wanted to show only limited details for better clarity of outputs. In Examples, we will see various types of uses and situations where we can use Format-Tablecommands to customize output format.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

How to Format the Table in PowerShell?

See the below syntax we use for formatting our outputs.

Syntax:

Format-Table
[-AutoSize(auto adjust output)] [-RepeatHeader(After each new screen show header for clarity)] [-HideTableHeaders(Delete the column overlapping from output structure)] [-Wrap(Show the details in the next line if it exceed column width)] [[-Property] <Show the object properties>] [-GroupBy <here we can group output in another table based on the properties .>] [-View <allow us for custom table>] [-ShowError(just to send error in Pipeline)] [-DisplayError(show error on command line)] [<CommonParameters>]

When we will be writing very big scripts at that time we would like to see minimum columns for better understanding, rather than displaying everything. In the below example we are first executing a command Get-Process, to see the whole process and it’s all other properties and output we got PM(K), PM(M), WS(M), CPU(s), ID, SI, Processname as the columns. Here we can see Get-Process is displaying every attribute of process, you may not be able to understand every property.

Get-Process

Output:

PowerShell Format Table 1-1

But this output is a little confusing as it showing all columns. Let’s assume we are only interested in the ProcessName field than what? Here we will use Format-Table command to get specific columns that we are looking for. Let’s write an example for it. see the below example.

Get-Process | Format-Table ProcessName, Handles -auto

Output:

PowerShell Format Table 1-2

In the above example, we are only displaying ProcessName.You can write your own command to get only process Id or CPU details.

Examples of PowerShell Format Table

Below are the examples of PowerShell Format Table:

Example #1

We have discussed various ways to use Format-Table command, now let’s explore little more utility about it. Suppose we want to get a formatted table with sorted by their start date. You can see screen output for reference. Here we are getting all the processes available inside our system along with sorted by their start time.

Get-Process | Sort-Object StartTime | Format-Table -View StartTime

Output:

Get-Process

Example #2 

If We want to see today’s date along with the display error. Many times to get a better understanding of errors we can use this command.

Get-Date | Format-Table DayOfWeek,{ $_ / $null } -DisplayError

Output:

-DisplayError

The output is showing Thursday along with column #ERR. You can also try it. You will get different output depending on the date on which you are running this command. These practices are good to use if it is expected to give some wrong outputs.

Example #3

Many times we want to see our output in the group by, for example, suppose you want to see the all group by an inactive process to kill them Or all the process started on the same group by date, Or you may need to see all the process on the basis of the group by basepriority. Let’s see the below example. In this example, we are formatting our output group by basepriority.

get-process | format-table -groupby basepriority

Output:

basepriority

Let’s take another example of the group by, where we are displaying all the output groups by their status. Please see the below example along with the screen. You can try more group by according to the properties of services. Always raise a question that why you need this command. Assume your application is running very slow because of many inactive processes. So you can write a command group buy status and kill all the inactive processes to improve your system performance.

get-process | format-table -groupby status

Output:

PowerShell Format Table 1-6

Group by can also be used for file and folder system, for example, suppose you want to see all the file in formatted way of it’s last used, group by last modified. Here we are passing LastAccessTime as an argument to Group by. Let me tell you one example suppose you have a folder where 1000 files are there and these files are created on a daily basis, now if you want to see newly created or modified files group by particular dates, then it will be very easy to do with Groupby command. Please refer to the below example with the screen.

Get-ChildItem ./ranjan | Format-List -GroupBy LastAccessTime

Output:

LastAccessTime

Example #4

Let’s write a command which will show all the properties of a folder in the new line. See the below example, here we are formatting output for ranjan folder and all the output we are getting in the newline. Here we can also define or restrict the number of columns to be displayed in the newline.

Get-Item -Path ./ranjan | Format-List

Output:

PowerShell Format Table 1-8

Example #5

You can use alias also in PowerShell, For example in PowerShell to write format-table in short form, we can write FT. Let me tell you one example where we are going to use alias FT. In the below example we are using FT to get all processes with only three columns, processName, Handle and PagedMemorySize. It will be useful if you are writing a big script, where you can use a smaller name to make your script smaller.

Get-Process | FT ProcessName, Handles, PagedMemorySize -auto

Output:

PagedMemorySize

Example #6

We can also show the output in more than one column. Here we have a command called format-wide (fw). This command will be useful if you are going to display output with a very long list but this long list contains only one field.

Get-Process | Get-Member -Membertype method | Format-Wide name -column 3

Output:

PowerShell Format Table 1-10

Conclusion

Format-Table is very useful where we have a very large and complex output format, in such type of situation we can define our own format to minified or modified format of output for better understanding.

Recommended Articles

This is a guide to PowerShell Format Table. Here we discuss the introduction and how to format the table in PowerShell along with the examples. You may also look at the following articles to learn more –

  1. Examples to Implement Remove-Item in PowerShell
  2. Working of PowerShell String Functions
  3. Guide to Different PowerShell Tools
  4. Learn the Parameters of PowerShell Get-Location
  5. Examples to Implement PowerShell Get-Date
  6. Top 8 Examples of PowerShell Break
  7. PowerShell Get-Item | Examples

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Limited Time Offer! - ENROLL NOW