3.11. Additional PowerShell Features

In this section, I introduce some additional features of PowerShell that can affect how you use it in several situations.

3.11.1. Extended Wildcards

PowerShell includes support for extended wildcards in the values for cmdlet parameters, although not all parameters allow wildcards. The following table shows the wildcards supported and briefly explains their meaning.

WildcardDescription
?Matches exactly one character in a specified position.
*Matches zero or more characters.
[abc]Matches a class of characters. One match is found for any of the characters inside the square brackets.
[a-c]Matches a range of characters. One match is found for any character between the character before the hyphen and the character after the hyphen.

NOTE

In addition to supporting an extended range of wildcards, Windows PowerShell also supports regular expressions.

Wildcards are useful when, for example, you want to see what files of a particular type are present in a directory. You can of course do that using Windows Explorer, by right-clicking in a folder, selecting Arrange Icons By Type. You still have to scan a potentially large number of files to find the files of the desired type.

In PowerShell you can access all the files in the folder C:\Windows\System32 by typing the command:

get-childitem –Path C:\Windows\System32

This returns a large number of files. To focus ...

Get Professional Windows® 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.