Chapter 12. Managing Documents

This chapter discusses the creation and use of different document types: text files, binary files, CSV files, and XML files. Examples in this chapter include searching in files, importing and exporting data in the CSV format, as well as reading, changing, transforming, and formatting XML documents.

Text Files

For reading files, Windows PowerShell (WPS) provides the commandlet Get-Content. By default, Get-Content reads the complete file.

Listing 12.1 demonstrates the entering of a text file and the row-by-row output using the commandlet Foreach-Object.

Example 12.1. Row-wise Entering of a Text File

$file = Get-Content j:\documents\protocol.csv ...

Get Essential PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.