Text files are great for storing simple, human-readable information, but they're not ideally suited to representing the structured data that we're becoming accustomed to in MSH. More often than not, we're dealing with objects and properties rather than strings and characters. MSH supports an additional data format with ease: comma-separated variables (CSV).
With two additional cmdlets for working with comma-separated data, easy-to-use spreadsheet applications can be combined with the power of the shell. Whether used for input (managing a task list in a friendly interface) or output (such as drawing graphs and performing statistical analysis), the CSV format can be very useful.
export-csv cmdlet takes a filename into which it writes a sequence of lines—one per object—with each field separated by a comma:
get-process | export-csv -NoTypeInformation processes.csv
The resulting file can now be used in an application such as Microsoft Excel or in other tools that can process CSV files. Figure 5-1 shows a graphical representation of handle count by process. The -
NoTypeInformation option is used to suppress the first line of the output (which would otherwise contain MSH-specific formatting information).
Figure 5-1. Graph generated from get-process data
export-csv also has a mirror cmdlet,
import-csv, that ...