PowerShell has a number of pattern-matching operators named wildcards that you can use to substitute one or more characters in a string, or substitute the complete string.
All wildcard expressions can be used with the PowerCLI cmdlets. For example, you can view a list of all files with a .txt extension by running dir *.txt
. In this case, the asterisk * operator matches any combination of characters.
With wildcard patterns you can indicate character ranges as well. For example, to view all files that start with the letter S or T and have a .txt extension, you can run dir [st]*.txt
.
You can use the question mark ? wildcard to match any single character within a sequence of characters. For example, to view all .txt files with names that consist of string and one more character at the end, run dir string?.txt
.