![]() ![]() The result will be the paths of all files that contain that string. Finally, we’ll use the ss alias on our filtered list of files to find all files containing the string “SqlConnection” which might be useful if you’re trying to ensure nobody is using ADO.NET when they should be using your ORM: ss SqlConnection $CSharpFiles | format-table Path.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.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”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |