{"id":6211,"date":"2022-03-15T21:33:01","date_gmt":"2022-03-15T19:33:01","guid":{"rendered":"https:\/\/lazyadmin.nl\/?p=6211"},"modified":"2023-06-14T10:33:50","modified_gmt":"2023-06-14T08:33:50","slug":"powershell-grep-select-string","status":"publish","type":"post","link":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/","title":{"rendered":"How to use PowerShell Grep equivalent Select-String"},"content":{"rendered":"\n<p>When you need to search through a string or log files in Linux we can use the <code>grep<\/code> command. For PowerShell, we can use the grep equivalent <code>Select-String<\/code>. We can get pretty much the same results with this powerful cmdlet.<\/p>\n\n\n\n<p>Select-String uses just like grep regular expression to find text patterns in files and strings. It can search through multiple files and report the location including the line number of the string for each file.   It&#8217;s also possible to find only the first occurrence of string or for example, return only the files that don&#8217;t match a string.<\/p>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">In this article<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f4a8f51f85f\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\" style='display:none' id=\"ez-toc-cssicon-toggle-item-69f4a8f51f85f\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#finding-a-string-with-powershell-select-string\" >Finding a String with PowerShell Select-String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#select-string-parameters\" >Select-String Parameters<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#showing-lines-before-and-after-with-context\" >Showing lines before and after with Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#return-true-or-false-with-quiet\" >Return True or False with Quiet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#return-only-the-matched-string-with-raw\" >Return only the matched string with Raw<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#search-through-multiple-file-types\" >Search through multiple file types<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#list-only-the-files-with-select-string\" >List only the files with Select-String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#return-lines-without-pattern\" >Return lines without pattern<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#find-files-that-not-match-pattern\" >Find files that not Match pattern<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#powershell-select-string-recursive\" >PowerShell Select-String Recursive<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#powershell-select-string-multiple-patterns\" >PowerShell Select-String Multiple Patterns<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#wrapping-up\" >Wrapping Up<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>In this article, we are going to take a look at the PowerShell grep equivalent <code>Select-String<\/code>. We are going to take a look at different examples that you can use to find a string with PowerShell. Make sure you read through the end for a nice little bonus tip!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"finding-a-string-with-powershell-select-string\"><\/span>Finding a String with PowerShell Select-String<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before we dive into all the possibilities of the <code>select-string<\/code> cmdlet, let&#8217;s first take a look at a couple of common examples. To search for a particular string in log files we can use the following cmdlet in PowerShell:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Search for the string error in the path\nSelect-String -Pattern \"error\" -Path \"C:\\temp\\log\\*.log\"\n\n# or in short:\nSelect-String \"error\" \"C:\\temp\\log\\*.log\"<\/pre>\n\n\n\n<p>The grep equivalent would be:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">grep \"error\" .\\log\\*.log<\/pre>\n\n\n\n<p>By default, the output of the select-string cmdlet will show the filename, line number, and the complete line where the string was found:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"949\" height=\"412\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21.jpg\" alt=\"powershell grep equivalent\" class=\"wp-image-6212\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21.jpg 949w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21-300x130.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21-768x333.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21-800x347.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21-400x174.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_11h47_21-50x22.jpg 50w\" sizes=\"(max-width: 949px) 100vw, 949px\" \/><figcaption class=\"wp-element-caption\">Powershell Grep Equivalent<\/figcaption><\/figure>\n\n\n\n<p>The advantage of PowerShell is that we can easily format the output to a more readable format. If you for example are only interested in the filename, path, and line number then you could format the results into a table and select only the fields that you need:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\" -Path \"C:\\temp\\log\\*.log\" | Select LineNumber, FileName, Path\n\n# Result:\nLineNumber Filename         Path\n---------- --------         ----\n         9 01032022-app.log C:\\temp\\log\\01032022-app.log\n        18 04032022-app.log C:\\temp\\log\\04032022-app.log\n         7 05032022-app.log C:\\temp\\log\\05032022-app.log\n         9 11022022-app.log C:\\temp\\log\\11022022-app.log\n         9 11032021-app.log C:\\temp\\log\\11032021-app.log\n         9 11102021-app.log C:\\temp\\log\\11102021-app.log\n        38 11102021-app.log C:\\temp\\log\\11102021-app.log\n         9 15032022-app.log C:\\temp\\log\\15032022-app.log<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"select-string-parameters\"><\/span>Select-String Parameters<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So we have taken a quick look at the basic usage of the cmdlet, now let&#8217;s dive a bit deeper into all the possibilities of the search-string cmdlet in PowerShell. The cmdlet comes with a couple of parameters that will help us with searching for strings and selecting the results:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>-Pattern<\/td><td>The text or string to find. Accepts a regular expression<\/td><\/tr><tr><td>-Path<\/td><td>Specify the file or path to files to search through. Accepts wildcards<\/td><\/tr><tr><td>-CaseSensitive<\/td><td>Search-string is case sensitive<\/td><\/tr><tr><td>-Context<\/td><td>Show lines before and\/or after the pattern<\/td><\/tr><tr><td>-Quiet<\/td><td>Only return true or false<\/td><\/tr><tr><td>-Raw<\/td><td>Return only the matched string like grep<\/td><\/tr><tr><td>-List<\/td><td>List only the first match in the files. Used to get a list of files with pattern<\/td><\/tr><tr><td>-SimpleMatch<\/td><td>Treat the pattern as a simple string<\/td><\/tr><tr><td>-Include<\/td><td>Specifies files to include in the search (&#8220;*.txt&#8221;,&#8221;*.log&#8221;)<\/td><\/tr><tr><td>-Exclude<\/td><td>Specifies files to exclude from the search path<\/td><\/tr><tr><td>-NotMatch<\/td><td>Return only the items that didn&#8217;t match the pattern<\/td><\/tr><tr><td>-AllMatches<\/td><td>Return all matches of the result<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Select-String Parameters<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"context\"><span class=\"ez-toc-section\" id=\"showing-lines-before-and-after-with-context\"><\/span>Showing lines before and after with Context<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The Select-String cmdlet returns the line where it found the string that we searched for. But when searching through log files, for example, you probably also want to know what happened before or after the error.<\/p>\n\n\n\n<p>This is where the -context parameter comes in. It allows you to specify the number of lines that need to be returned for and\/or after the matched line. The first digit is the number of lines before, the second is the number of lines after. If you only supply a single digit then it will be used for both.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Return 3 lines before\nSelect-String -Pattern \"error\" -Path \"C:\\temp\\log\\sub\\*.log\" -Context 3,0\n\n# Return 2 lines before and 2 lines after the error:\nSelect-String -Pattern \"error\" -Path \"C:\\temp\\log\\sub\\*.log\" -Context 2<\/pre>\n\n\n\n<p>The line that matched the pattern is indicated with <code>&gt;<\/code> and the string is highlighted:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08.jpg\" alt=\"powershell select-string\" class=\"wp-image-6213\" width=\"797\" height=\"195\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08.jpg 886w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08-300x73.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08-768x188.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08-800x196.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08-400x98.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_13h28_08-50x12.jpg 50w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><figcaption class=\"wp-element-caption\">PowerShell Select-String cmdlet<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"quiet\"><span class=\"ez-toc-section\" id=\"return-true-or-false-with-quiet\"><\/span>Return True or False with Quiet<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When using the PowerShell grep equivalent select-string inside a script you sometimes only need to know if the string exists or not. By default, the cmdlet will return a MatchInfo object. An object with the line number, path, string, etc.<\/p>\n\n\n\n<p>To check if the log files contain an error or not we can do the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Returns true or False\nSelect-String -Pattern \"error\" -Path \"C:\\temp\\log\\sub\\*.log\" -Quiet\n\n# Result:\nTrue<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"raw\"><span class=\"ez-toc-section\" id=\"return-only-the-matched-string-with-raw\"><\/span>Return only the matched string with Raw<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you are used to the Linux grep command then you may have noticed that the result of select-string is slightly different. The PowerShell equivalent returns an object, instead of only the string that the grep command does.<\/p>\n\n\n\n<p>When you add the -raw parameter to your command then the cmdlet will only return the string that matched the pattern:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\" -Path \"C:\\temp\\log\\sub\\*.log\" -Raw\n\n# Result:\n2022-03-01 10:59:21 [ERROR] - String failed to be a string<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"multiple-file-types\"><span class=\"ez-toc-section\" id=\"search-through-multiple-file-types\"><\/span>Search through multiple file types<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The path parameter already accepts wildcards, allowing us to search through multiple files. But in this case, we can only search through one file type. When using the <code>-include<\/code> parameter we can specify multiple file types that we want to search through.<\/p>\n\n\n\n<p>To use the parameter we still need to supply the path, otherwise, the cmdlet will search in the script root location.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Search in the txt and log files\nSelect-String -Pattern \"error\" -Path \"C:\\temp\\log\\sub\\*\" -Include \"*.txt\",\"*.log\"\n\n# Result\nC:\\temp\\log\\sub\\LT3452-process.log:4:2022-03-01 10:59:21 [ERROR] - String failed to be a string\nC:\\temp\\log\\sub\\LT4423-process.txt:3:2022-02-01 05:49:21 [ERROR] - Squirrel failed to find process<\/pre>\n\n\n\n<p>It&#8217;s also possible to exclude file extensions with the <code>-exclude<\/code> parameter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"only-files\"><span class=\"ez-toc-section\" id=\"list-only-the-files-with-select-string\"><\/span>List only the files with Select-String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When searching through multiple files with the <code>select-string<\/code> cmdlet, PowerShell will return all instances of the string that it has found. But sometimes you only want to know if a log file, for example, contains an error.<\/p>\n\n\n\n<p>If we search through the log files for the pattern error we can see that the file 11102021-app.log is found two times:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"11,12\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\" -Path \"C:\\temp\\log\\*\" | Select LineNumber, Filename\n\n# Result:\nLineNumber Filename\n---------- --------\n         9 01032022-app.log\n        18 04032022-app.log\n         7 05032022-app.log\n         9 11022022-app.log\n         9 11032021-app.log\n         9 11102021-app.log\n        38 11102021-app.log\n         9 15032022-app.log<\/pre>\n\n\n\n<p>By using the parameter -List only the first instances are returned, resulting in a unique list of filenames that contain the matching pattern:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\" -Path \"C:\\temp\\log\\*\" -List | Select LineNumber, Filename<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"886\" height=\"247\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12.jpg\" alt=\"List only files\" class=\"wp-image-6214\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12.jpg 886w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12-300x84.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12-768x214.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12-800x223.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12-400x112.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_14h03_12-50x14.jpg 50w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><figcaption class=\"wp-element-caption\">Unique files with -list parameter<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"return-lines-without-pattern\"><\/span>Return lines without pattern<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>All this time we have been searching for strings inside log files that contain the string &#8220;error&#8221;. But what if you want to get the opposite? All <strong>the lines<\/strong> that don&#8217;t contain the word &#8220;error&#8221;?<\/p>\n\n\n\n<p>For this, we can use the <code>-NotMatch<\/code> parameter. This will return all the lines in the path that don&#8217;t match the pattern that we have supplied:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\" -Path \"C:\\temp\\log\\*\" -NotMatch | Select LineNumber, Filename<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"find-files-that-not-match-pattern\"><\/span>Find files that not Match pattern<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The Select-String cmdlet searches on line level through files. This means that we can&#8217;t simply use this cmdlet to return only the files that don&#8217;t contain a particular string.<\/p>\n\n\n\n<p>To get all the files that don&#8217;t contain the string we will need to use the <code>Get-ChildItem<\/code> cmdlet, and use the <code>Select-String<\/code> cmdlet on each file.<\/p>\n\n\n\n<p>By using the <code>-quiet<\/code> parameter we can return true or false, allowing us to only select (and return) the files that don&#8217;t contain the pattern:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-ChildItem -path \"C:\\temp\\log\\*\" | Where-Object { !( $_ | Select-String -Pattern \"error\" -Quiet ) }\n\n# Result:\n\n    Directory: C:\\temp\\log\n\nMode                 LastWriteTime         Length Name\n----                 -------------         ------ ----\nd----           15-3-2022    13:52                sub\n-a---           15-3-2022    14:09           4120 04032022-app.log\n-a---           15-3-2022    12:59           2860 11032022-app.log<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Select-String-Recursive\"><span class=\"ez-toc-section\" id=\"powershell-select-string-recursive\"><\/span>PowerShell Select-String Recursive<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The select-string cmdlet in PowerShell only searches in the given directory. It won&#8217;t go through the subfolders, even if you use wildcards. To search in all subfolders as well we will need to combine the cmdlet with <code>Get-ChildItem<\/code>.<\/p>\n\n\n\n<p>So to search in all subfolders we first will get all the items with <code>Get-Childitem<\/code> using the parameter <code>-Recurse<\/code> to search recursively. And then pass each file to the <code>Select-String<\/code> cmdlet:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Get-ChildItem -path \"C:\\temp\\log\\*\" -Recurse | Select-String -Pattern \"error\" | Select LineNumber, Filename, Path<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48.jpg\" alt=\"PowerShell Select-String Recursive\" class=\"wp-image-6216\" width=\"797\" height=\"262\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48.jpg 886w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48-300x99.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48-768x253.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48-800x264.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48-400x132.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_19h59_48-50x16.jpg 50w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><figcaption class=\"wp-element-caption\">PowerShell Select-String Recursive<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Multiple-Patterns\"><span class=\"ez-toc-section\" id=\"powershell-select-string-multiple-patterns\"><\/span>PowerShell Select-String Multiple Patterns<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When searching through log files of other text files you sometimes need to search for multiple patterns. Now you could simply run the <code>Select-String<\/code> cmdlet twice, but that isn&#8217;t really efficient.<\/p>\n\n\n\n<p>Luckily we can supply multiple patterns to the <code>Select-String<\/code> cmdlet. You can simply create an array with strings or comma-separated the strings:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Select-String -Pattern \"error\",\"warning\" -Path \"C:\\temp\\log\\*\" -List | Select LineNumber, Filename, Pattern<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"893\" height=\"292\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10.jpg\" alt=\"Multiple Patterns\" class=\"wp-image-6217\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10.jpg 893w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10-300x98.jpg 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10-768x251.jpg 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10-800x262.jpg 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10-400x131.jpg 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/2022-03-15_20h12_10-50x16.jpg 50w\" sizes=\"(max-width: 893px) 100vw, 893px\" \/><figcaption class=\"wp-element-caption\">Multiple Patterns<\/figcaption><\/figure>\n\n\n\n<p>As you can see I have added the property Pattern to the select statement. This way we can see which pattern has matches in the file and on which line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"wrapping-up\"><\/span>Wrapping Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The PowerShell grep equivalent Select-String is a great tool to find strings inside text files or other output streams. If you really like to use the command grep, then I have a small tip for you. You can create a new alias in PowerShell so that the select-string cmdlet is used when you type grep.<\/p>\n\n\n\n<p>To create the alias type:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">new-alias grep select-string<\/pre>\n\n\n\n<p>Now you can use grep just like in Linux:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"893\" height=\"202\" src=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8.png\" alt=\"grep powershell\" class=\"wp-image-6219\" srcset=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8.png 893w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8-300x68.png 300w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8-768x174.png 768w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8-800x181.png 800w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8-400x90.png 400w, https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/image-8-50x11.png 50w\" sizes=\"(max-width: 893px) 100vw, 893px\" \/><figcaption class=\"wp-element-caption\">Grep Alias<\/figcaption><\/figure>\n\n\n\n<p>I hope you found this article useful, if you have any questions, just drop a comment below.<\/p>\n<script async src=\"https:\/\/alatus.eocampaign1.com\/form\/d0ce5de8-9b48-11ee-8cf4-eb425eea7369.js\" data-form=\"d0ce5de8-9b48-11ee-8cf4-eb425eea7369\"><\/script>","protected":false},"excerpt":{"rendered":"<p>When you need to search through a string or log files in Linux we can use the grep command. For PowerShell, we can use the grep equivalent Select-String. We can get pretty much the same results with this powerful cmdlet. &#8230; <a title=\"How to use PowerShell Grep equivalent Select-String\" class=\"read-more\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\">Read more<span class=\"screen-reader-text\">How to use PowerShell Grep equivalent Select-String<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":6222,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[69],"tags":[22],"class_list":["post-6211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"wppr_data":{"cwp_meta_box_check":"No"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin<\/title>\n<meta name=\"description\" content=\"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin\" \/>\n<meta property=\"og:description\" content=\"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\" \/>\n<meta property=\"og:site_name\" content=\"LazyAdmin\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/lazyadminnl\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-15T19:33:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-14T08:33:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"450\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rudy Mens\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/lazyadmin\" \/>\n<meta name=\"twitter:site\" content=\"@lazyadmin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rudy Mens\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\"},\"author\":{\"name\":\"Rudy Mens\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"headline\":\"How to use PowerShell Grep equivalent Select-String\",\"datePublished\":\"2022-03-15T19:33:01+00:00\",\"dateModified\":\"2023-06-14T08:33:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\"},\"wordCount\":1272,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg\",\"keywords\":[\"Powershell\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\",\"url\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\",\"name\":\"How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin\",\"isPartOf\":{\"@id\":\"https:\/\/lazyadmin.nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg\",\"datePublished\":\"2022-03-15T19:33:01+00:00\",\"dateModified\":\"2023-06-14T08:33:50+00:00\",\"description\":\"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more\",\"breadcrumb\":{\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg\",\"width\":800,\"height\":450},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lazyadmin.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use PowerShell Grep equivalent Select-String\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lazyadmin.nl\/#website\",\"url\":\"https:\/\/lazyadmin.nl\/\",\"name\":\"LazyAdmin\",\"description\":\"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices\",\"publisher\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lazyadmin.nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952\",\"name\":\"Rudy Mens\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"contentUrl\":\"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg\",\"width\":500,\"height\":500,\"caption\":\"Rudy Mens\"},\"logo\":{\"@id\":\"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/\"},\"description\":\"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.\",\"sameAs\":[\"https:\/\/lazyadmin.nl\",\"https:\/\/www.facebook.com\/lazyadminnl\/\",\"http:\/\/nl.linkedin.com\/in\/rudymens\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin","description":"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/","og_locale":"en_US","og_type":"article","og_title":"How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin","og_description":"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more","og_url":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/","og_site_name":"LazyAdmin","article_publisher":"https:\/\/www.facebook.com\/lazyadminnl\/","article_author":"https:\/\/www.facebook.com\/lazyadminnl\/","article_published_time":"2022-03-15T19:33:01+00:00","article_modified_time":"2023-06-14T08:33:50+00:00","og_image":[{"width":800,"height":450,"url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg","type":"image\/jpeg"}],"author":"Rudy Mens","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/lazyadmin","twitter_site":"@lazyadmin","twitter_misc":{"Written by":"Rudy Mens","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#article","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/"},"author":{"name":"Rudy Mens","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"headline":"How to use PowerShell Grep equivalent Select-String","datePublished":"2022-03-15T19:33:01+00:00","dateModified":"2023-06-14T08:33:50+00:00","mainEntityOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/"},"wordCount":1272,"commentCount":3,"publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg","keywords":["Powershell"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/","url":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/","name":"How to use PowerShell Grep equivalent Select-String &#8212; LazyAdmin","isPartOf":{"@id":"https:\/\/lazyadmin.nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage"},"image":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage"},"thumbnailUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg","datePublished":"2022-03-15T19:33:01+00:00","dateModified":"2023-06-14T08:33:50+00:00","description":"Find strings with the PowerShell grep equivalent Select-String. Example inc recursive search, multiple patterns, and more","breadcrumb":{"@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#primaryimage","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg","width":800,"height":450},{"@type":"BreadcrumbList","@id":"https:\/\/lazyadmin.nl\/powershell\/powershell-grep-select-string\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lazyadmin.nl\/"},{"@type":"ListItem","position":2,"name":"How to use PowerShell Grep equivalent Select-String"}]},{"@type":"WebSite","@id":"https:\/\/lazyadmin.nl\/#website","url":"https:\/\/lazyadmin.nl\/","name":"LazyAdmin","description":"Tips and howto&#039;s about Office 365, PowerShell, Home network and smart devices","publisher":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lazyadmin.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/cbfba61543b21fbba63cfbf62f08d952","name":"Rudy Mens","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/","url":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","contentUrl":"https:\/\/lazyadmin.nl\/wp-content\/uploads\/2024\/06\/Profile-photo-2024-Ruud.jpg","width":500,"height":500,"caption":"Rudy Mens"},"logo":{"@id":"https:\/\/lazyadmin.nl\/#\/schema\/person\/image\/"},"description":"Ruud worked for more than 15 years as a SysAdmin in the Netherlands and is now working as an independent consultant. In his spare time, he loves to thinker with Smart Devices.","sameAs":["https:\/\/lazyadmin.nl","https:\/\/www.facebook.com\/lazyadminnl\/","http:\/\/nl.linkedin.com\/in\/rudymens\/","https:\/\/x.com\/https:\/\/twitter.com\/lazyadmin"]}]}},"uagb_featured_image_src":{"full":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",800,450,false],"thumbnail":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep-150x150.jpg",150,150,true],"medium":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep-300x169.jpg",300,169,true],"medium_large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep-768x432.jpg",768,432,true],"large":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",800,450,false],"1536x1536":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",800,450,false],"2048x2048":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",800,450,false],"post-thumb":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",800,450,false],"post-thumb-half":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep-400x225.jpg",400,225,true],"wppr-widget":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep-50x28.jpg",50,28,true],"gform-image-choice-sm":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",300,169,false],"gform-image-choice-md":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",400,225,false],"gform-image-choice-lg":["https:\/\/lazyadmin.nl\/wp-content\/uploads\/2022\/03\/powershell-grep.jpg",600,338,false]},"uagb_author_info":{"display_name":"Rudy Mens","author_link":"https:\/\/lazyadmin.nl\/author\/lajcud8123b\/"},"uagb_comment_info":3,"uagb_excerpt":"When you need to search through a string or log files in Linux we can use the grep command. For PowerShell, we can use the grep equivalent Select-String. We can get pretty much the same results with this powerful cmdlet. ... Read moreHow to use PowerShell Grep equivalent Select-String","_links":{"self":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/6211"}],"collection":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/comments?post=6211"}],"version-history":[{"count":0,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/posts\/6211\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media\/6222"}],"wp:attachment":[{"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/media?parent=6211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/categories?post=6211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lazyadmin.nl\/wp-json\/wp\/v2\/tags?post=6211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}