Windows PowerShell provides a .Net environment that provides a powerful command line shell, and a scripting environment for the windows platform. PowerShell is useful for a number of tasks, including system administration.
The PowerShell pipeline facilitates passing the output of a command as input to another. Pipelines are a common mechanism for joining commands for example the Linux shell provides this feature.
You can think of a cmdlet as being similar to a shell command. A cmdlet performs a task. PowerShell comes with a number of cmdlets that follow a particular naming convention. They follow a Verb-Noun naming convention e.g. Get-Process, Get-ChildItem, Get-Command etc.
PowerShell offers a number of cmdlets for working with files. Sometimes we may need to retrieve the contents of file, to display it, or process it. PowerShell provides a number of different ways to access the contents of a file.
Regular expressions provide a powerful mechanism to search a file for text that has a particular pattern. We can use a regular expression to define a particular pattern. For example, we can define a regular expression to match a phone number, email, Uniform Resource Locator (URL) etc. We can define a regular expression to match a piece of text.
PowerShell provides functionality to search the contents of one or more files for a pattern. The Select-String cmdlet enables us to achieve this goal.
A very common task is to compare two files for differences. We may perform this task as part of a post install verification process. PowerShell provides a couple of Cmdlets that aid with this activity.
Sometimes we find the need to create files. We can create files with PowerShell. There are a number of different ways to create a file. We will look at some of the mechanisms here.
We can use PowerShell to find files modified after a certain date. This task can be useful to find recently modified files on a system. We can use the Get-ChildItem cmdlet to perform this task. The Get-ChildItem CmdLet provides the Recurse parameter which allows us to search in child directories.
We can use PowerShell to monitor files for changes. The Get-Content Cmdlet provides the Wait parameter. The wait parameter will monitor the end of a file for any changes. This task can be useful in a number of situations such as monitoring a log file for changes.