O'Reilly logo

Windows PowerShell™ 2 For Dummies® by Steve Seguis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Readin' and Writin' Files

In This Chapter

  • Navigate through the file system

  • Manage your files and folders

  • Create your own data format using XML

  • Make your output presentable using HTML

Although it's great to perform calculations and do all kinds of fun stuff in the Windows PowerShell console, many times you need to store data somewhere such as in a file or database. The easiest and most direct place to store data for long-term use is a file. Windows PowerShell not only makes reading and writing simple text files easy, but also lets you create even more complex files, like XML and HTML files.

In this chapter, you exercise your ability to both act as a producer and consumer of files within your file system. Many files are created by people but even more are automatically created by computers through programs and scripts, so your ability to read, write, and even manage files within your file system becomes a necessary skill, just like being able to use a remote is to a couch potato.

Having Some Fun with the File System

One of the most fundamental skills you need to possess as a Windows PowerShell user is the ability to manipulate files within the file system. This manipulation includes creating, deleting, copying, moving, and renaming files and folders. Sure, you can go back to using Windows Explorer, but have you ever tried renaming 100 files by using the Windows GUI? Not much fun, was it? How about deleting files matching a certain pattern? I can think of quite a few scenarios ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required