PowerShell NoTypeInformation Parameter Explained

Photo of author

By Victor Ashiedu

Published

Are you wondering what NoTypeInformation does in PowerShell? This guide provides a detailed explanation of this Powershell parameter.

Overview

When you use some PowerShell cmdlets to export data to csv, convert to csv or export to XML, the operation includes the #TYPE information header by default.

So, what is #TYPE information?

Every PowerShell object has a TypeName. For example, the TypeName for Get-Process is System.Diagnostics.Process.

The TypeName of an object is the .Net class of that object. One way to display the type information of an object is to pipe the output of the cmdlet to the Get-Member cmdlet.

For example, to see the TypeName for Get-Process, run the command below:

Get-Process | Get-Member

The Get-Member cmdlet displays the properties and methods of a cmdlet. But before that, on top of the properties and methods, it displays the TypeName.

As you can see from the screenshot below, the TypeName of Get-Process is System.Diagnostics.Process.

I know that you must be wondering how all of these relate to the Powershell NoTypeInformation parameter.

Here is how:

When you export the output of some cmdlets to csv using the Export-csv cmdlet, the Export-csv includes the type information returned by the original cmdlet into the csv file’s header.

Apart from the Export-csv cmdlet, there are two other cmdlets that feature the Powershell NoTypeInformation parameter. I’ll discuss this in the next section.

If you want the type information to be excluded from the exported file’s header, then you need to include the NoTypeInformation parameter in the Export-csv command.

It is essential to mention that from PowerShell version 6.0, you do not need to specify the NoTypeInformation to remove the #TYPE information from the header of the exported file.

In the examples section of this guide, I have some examples that demonstrate how PowerShell version 6.0 and upwards handle #TYPE information compared to previous versions of PowerShell.

Cmdlets that Use the NoTypeInformation Parameter

In the last section, I hinted that there are three cmdlets that feature the NoTypeInformation parameter.

Run the command below to get a list of cmdlets that feature the NoTypeInformation parameter.

Get-Command -ParameterName NoTypeInformation

As you can see from the screenshot below, the three PowerShell cmdlets that feature the NoTypeInformation parameter are Export-Csv, ConvertTo-Csv and ConvertTo-Xml.

Syntax of the NoTypeInformation Param

Since the NoTypeInformation is a parameter of cmdlets, it does not have its own syntax. The syntax of the NoTypeInformation is effectively the syntax of the cmdlet that features the parameter.

So, here are the basic syntaxes of the three cmdlets that feature the NoTypeInformation parameter.

Export-Csv -Path <full path to the csv file> -NoTypeInformation 
ConvertTo-Csv [-InputObject] -NoTypeInformation 
ConvertTo-Xml [-InputObject] -NoTypeInformation 
These cmdlets have other parameters that I did not include in the above syntaxes. To see the full syntax of a cmdlet, use the commands below.
Get-Help Export-Csv
Get-Help ConvertTo-Csv
Get-Help ConvertTo-Xml

Earlier I mentioned that from PowerShell version 6.0, the default behavior of these cmdlets is to exclude the #TYPE information. So, from 6.0, Export-Csv and ConvertTo-Csv include a parameter called IncludeTypeInformation.

This parameter was introduced so that if you need to include the #TYPE information, you can call the IncludeTypeInformation parameter.

Examples and Applications

Now that you have some information about the Powershell NoTypeInformation parameter, it’s time to see some examples and applications.

How To Use Export-Csv PowerShell Cmdlet With NoTypeInformation Parameter

This is the most natural place to start, as you’re likely to have the need to remove the #TYPE information header by using the Export-Csv command.

To demonstrate how to use Export-Csv with the NoTypeInformation parameter, I’ll export the output of Get-Service to csv.

Firstly, I’ll run the command without the Export-Csv’s NoTypeInformation parameter.

Get-Service | Export-Csv D:\report\service_without_NoTypeInformation.csv

Here is the result of the command displaying the #TYPE information on the csv file’s header.

How To Use Export-Csv PowerShell Cmdlet With NoTypeInformation Parameter

To remove the “TYPE System.ServiceProcess.ServiceController” from the csv file’s header, I’ll run the last command, but this time, I’ll include the NoTypeInformation parameter.

Get-Service | Export-Csv D:\report\service_with_NoTypeInformation.csv -NoTypeInformation

This time the “TYPE System.ServiceProcess.ServiceController” is no longer at the csv file’s header.

Earlier, I mentioned that from PowerShell version 6.0, when you run the Export-Csv command, you no longer need to include the NoTypeInformation parameter.

This is because, from PowerShell version 6.0, the Export-Csv command no longer includes #TYPE information on the csv file’s header.

Now, I’ll run the last command from my PowerShell version 7.2 console.

Get-Service | Export-Csv D:\report\service_without_NoTypeInformation_PS7.2.csv

Bingo, the is no #TYPE information on the csv file’s header!

How To Use Export-Csv PowerShell Cmdlet With NoTypeInformation Parameter

But what if I want to include the #TYPE information on the csv file’s header? In that case, when I run the command in PowerShell v6.0 and above, I’ll include a parameter called IncludeTypeInformation.

Get-Service | Export-Csv D:\report\service_with_IncludeTypeInformation_PS7.2.csv -IncludeTypeInformation

This time, the #TYPE information will return to the csv file’s header!

How to Use Select-Object and Export-csv with NoTypeInformation

In the last example, I exported the output of the Get-Service to csv. However, I explored all headers. But what if I want to only show the Name and Status of the service.

In that case, I will introduce the Select-Object command. Here is a sample command.

Get-Service | Select-Object Name, Status | Export-Csv D:\report\service_with_NoTypeInformation.csv -NoTypeInformation

The command returned all services on my computer but only shows the Names and Status of the services.

How To Use Select-Object And Export-csv With NoTypeInformation

How to Use ConvertTo-Csv PowerShell Cmdlet wWith NoTypeInformation Parameter

To demonstrate how to use ConvertTo-Csv with NoTypeInformation, let’s start by running the Get-Process command to return a process called ACCSvc.

Get-Process ACCSvc

As expected, the command returns the process in a tabular format.

But what if I want to return the information in CSV (comma-separated values). To achieve this, I will pipe the output of the Get-Process command to ConvertTo.Csv

Get-Process ACCSvc | ConvertTo-Csv

The above command does a good job of converting the output of Get-Process to csv. However, it left the “TYPE System.Diagnostics.Process” #TYPE information above the result.

To get rid of “TYPE System.Diagnostics.Process”, I’ll include the NoTypeInformation Parameter in the Powershell ConvertTo-Csv cmdlet.

Get-Process ACCSvc | ConvertTo-Csv -NoTypeInformation

Now, “TYPE System.Diagnostics.Process” is no longer in the result. But, one more task may be required to complete this process.

Most administrators will want to export this information to a CSV file. To achieve this, I’ll now pipe the output of the last command to the Out-File command.

Note that I used the .csv file extension because I want the output to be a CSV file. I could also export the result to a text file. In that case, I would have used a .txt file extension.
Get-Process ACCSvc | ConvertTo-Csv -NoTypeInformation | Out-File D:\report\Process_NoTypeInformation.csv

How to Append Data with Export-Csv’s NoTypeInformation

The Export-Csv cmdlet has an Append parameter. When you specify the Append parameter, Export-Csv adds output to the end of a specified file.

Otherwise, without including the Append parameter, Export-Csv overwrites the file with new information. At this point, you may be thinking that when you append information to a csv file, the Export-Csv cmdlet will also include the #TYPE information.

Surprisingly, when you append the information to a csv file even without using the NoTypeInformation parameter, the Export-Csv cmdlet does NOT include the #TYPE information. Let’s see how these theories work in real PowerShell commands.

I’ll start by creating a csv that contains a single process called ACCSvc.

Get-Process ACCSvc | Export-Csv D:\report\Process_append.csv -NoTypeInformation
I intentionally included the NoTypeInformation parameter in this command to remove the #TYPE information from the csv file’s header.

Here is the result of the last command in a csv file.

In this next step, I want to append another process called AgentSvc. To add this information to the end of the csv file, I’ll include the Append parameter.

Get-Process AgentSvc | Export-Csv D:\report\Process_append.csv -Append

The result of the screenshot below shows that the above command did not include the #TYPE information before appending the next line to the csv file.

Frequently Asked Questions

1. What does NoTypeInformation do in PowerShell?

The NoTypeInformation removes the #TYPE information header when you use the Export-Csv or ConvertTo-Csv to export PowerShell output to a CSV file.

Prior to PowerShell version 6, #TYPE information header is included by default. However, from version 6, this information is removed by default.

2. How do I export from PowerShell to CSV?

To export the output of a PowerShell command to CSV, use the Export-CSV or ConvertTo-Csv cmdlets. Then, specify the full path to the csv file, including the file extension (.csv).

3. How do I read a CSV file in PowerShell?

To read a CSV file in PowerShell, use the Import-CSV command. Learn more about the Import-Csv.

4. How do I export a text file in PowerShell?

There are 3 cmdlets you can use to export to a text file in PowerShell – Add-Content, Out-File, and Set-Content.

To learn more, read my guide – PowerShell Write to File – 17 SysAdmin Examples

5. How do I read or import a text file in PowerShell?

To read a text file in PowerShell, use the Get-Content command.

Conclusion

The Powershell NoTypeInformation parameter is a very useful parameter that eliminates the annoying #TYPE information header from a csv file.

Without it (at least in PowerShell versions prior to 6.0), you will not be able to eliminate the #TYPE information header from a csv file exported with the Export-CSV or ConvertTo-Csv cmdlets.

However, as I hinted in the last paragraph, from PowerShell version 6, you do not need to specify the NoTypeInformation parameter anymore. This is because from 6.0 upwards, PowerShell does not include the #TYPE information header.

Rather, if you need to include this information, use the IncludeTypeInformation parameter. The IncludeTypeInformation parameter is available from PowerShell version 6.0.

I hope I was able to make it easy for you to understand the Powershell NoTypeInformation parameter. I also hope that you found the examples helpful?

If you found this guide helpful and easy to understand, kindly spare 2 minutes to share your experience with us.

On the other hand, if you still have a question about the Powershell NoTypeInformation parameter, use the form at the bottom of this page to ask your question.

Alternatively, you can respond to the “Was this page helpful?” question below.

Finally, to read more PowerShell Explained articles, visit our Windows PowerShell Explained page.

We go the extra mile to deliver the highest quality content for our readers. Read our Content Writing, Content Review, and Anti-Plagiarism policies to learn more.

About the Author

Photo of author

Victor Ashiedu

Victor is the founder of InfoPress Media, publishers of Ilifeguides and Itechguides. With 20+ years of experience in IT infrastructure, his expertise spans Windows, Linux, and DevOps. Explore his contributions on Itechguides.com for insightful how-to guides and product reviews.

Related Articles

Get in Touch

If this article does not meet your expectations, kindly let us know. We have various ways you can get in touch with us:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend