PowerShell 2.0 and later
Let’s assume you want the user to submit a list of file extensions, or you are getting them from some other source.
File extensions are a perfect example of fuzzy standards. How would you specify a text file extension? Is it “.txt”, or is it “*.txt”?
Here is a simple trick that normalizes file extensions, regardless of how they were specified:
$extensions = '*.ps1', '.txt' $cleanExtensions = $extensions -replace '^\.', '*.' $extensions $cleanExtensions