For example, the Select-String command is useful for matching files that contain a particular string, but if you’d prefer to just type “ss” for this, you can alias it like so: Set-Alias ss Select-String The next step is again not strictly necessary since we could simply write out the command, but it does show another useful PowerShell feature, namely the ability to alias commands with shorthand strings.
POWERSHELL FILE EXTENSION FULL
The full command to create a new collection named $CSharpFiles is: $CSharpFiles = $AllFiles | where Note that the $_ value refers to the current item in the collection as we loop through them applying our filter condition. If we’re looking for all of our C# source files, we would search for extensions that end with “.cs”. Next we’ll filter our list to only include files with the extension we want.
![powershell file extension powershell file extension](http://vcloud-lab.com/files/images/save-powershell-ps1-file-format-extension-from-notepad-with-double-quote.png)
To get a collection of all the files in and below your current folder, use: $AllFiles = Get-ChildItem –recurse This isn’t strictly required but again using an intermediate step like this can ensure you catch any mistakes in your operation earlier. The standard “cd” command from DOS works for this, but remember you can’t do “cd” you have to do “cd ” to move to the root of the current volume. While not strictly necessary, this will make your life easier. To get a list of all files with a given extension that contain a given string, you can use the following steps (click on the screenshot to see it full size) I use PowerShell all the time now to make downloading pictures from my camera and organizing them by date easy Being able to easily store collections of objects in ad-hoc variables (named $something) and then to further be able to pipe the output of anything to anything (using | just like most other shells), you can quickly do some amazing stuff. I’m guessing there actually *is* a way to do this from the GUI, but after spending a couple of minutes either searching all files for the text “.cs” or else searching for files named “connection” I opted to just do it from the command line using PowerShell.
![powershell file extension powershell file extension](https://fileproinfo.com/images/ps1_file_extension.png)
POWERSHELL FILE EXTENSION WINDOWS
In any event, I tried using the default Windows Vista file search dialog, but found that if I wanted to search for “connection” or “database” within all files ending with “.cs” or “.config” I was unable to do so. I often find myself missing UNIX’s grep tool. This week I found myself wanting to search within files of a given extension for a particular substring.