There is a special parameter that can be used with just about any PowerShell command or cmdlet in order to display different, and usually more, data from that particular command. This parameter is called Format-List, and if you are a fan of finding as much information as possible about the tools you are working with, this is something you will definitely want to become familiar with. PowerShell is often used to monitor many different facets of Windows Server, and getting to know the intricacies of Format-List will certainly help you to sculpt the output information that you are looking for when performing monitoring functions from the PowerShell command line.
We all know that a dir
command will display a list of files and folders that are within our current directory; this works in either Command Prompt or in PowerShell. Let's start learning how to make use of Format-List by using it to modify the output of our dir
information.
We will be running these commands from a PowerShell prompt on one of our Windows Server 2016 machines.
Let's use Format-List to modify our information output on a couple of different PowerShell cmdlets:
documents
folder, so I will input cd documents
in order to navigate into my documents
folder.dir
. Then press Enter. You see the normal output of the dir
command, a simple list of files, and a little bit of information about each of them.
dir
, give this command a try: Dir | Format-List
.dir
command to give us more information about these files.
*
to the end of the command. Let's give that a try.Dir | Format-List *
.
Get-Date
cmdlet to see the current date and time. Pretty simple, right?
Get-Date | Format-List
.
As we have shown in this recipe, using the Format-List parameter on the end of any command or cmdlet is a good practice to get into because it can help display much more information than would normally be available with the original command, from system timestamps and file information up to very specific information about NIC settings and system components; making Format-List part of your regular arsenal will therefore help to get you a greater quantity of information that you can use to do your job.
13.59.27.141