13

I am using the following PowerShell script to obtain Name, DisplayName, State, StartMode and PathName of all windows services of a local machine and then export the output to a csv file using the Export-csv cmdlet,

Get-WmiObject win32_service | Select Name, DisplayName, State, StartMode, PathName | Export-Csv C:/ListOfServices.csv

the script works fine but the problem is, the first row of the output csv file contains

#TYPE Selected.System.Management.ManagementObject

Is there any way to exclude this line from the output? I am preparing a script to get all these details from all server machines in the network, so excluding this line becomes important.

Abilash A
  • 951
  • 2
  • 8
  • 14

2 Answers2

25

Add the -NoTypeInformation switch in your Export-CSV command, like this:

Get-WmiObject -Class win32_service |
Select Name, DisplayName, State, StartMode, PathName |
Export-Csv -NoTypeInformation -Path C:/ListOfServices.csv
Frode F.
  • 52,376
  • 9
  • 98
  • 114
  • Thanks for your great help, the `-NoTypeInformation` switch works great, this is what I was looking for – Abilash A Jul 07 '14 at 09:04
1

you need to include -NoTypeInformation in export-csv command to avoid

TYPE Selected.System.Management.ManagementObject

ex: Export-Csv -Path "your path for the export file" -NoTypeInformation

Community
  • 1
  • 1
Pradeep
  • 155
  • 3
  • 10