File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,7 +79,11 @@ function Search-PipeScript {
7979 return $true
8080 })]
8181
82- $RegularExpression
82+ $RegularExpression ,
83+ # If set, will search nested script blocks.
84+ [Alias (' SearchNestedScriptBlock' )]
85+ [switch ]
86+ $Recurse
8387 )
8488 process {
8589 $ScriptBlock = $null
@@ -167,12 +171,15 @@ function Search-PipeScript {
167171 [ScriptBlock ]::Create(' param($ast) $ast.GetType().Name -like "*' + $astType + ' *"' )
168172 }
169173
174+ # Add this condition to the list of conditions.
170175 $AstCondition += $condition
171176 }
172177 }
178+ # If we have any AST conditions
173179 if ($AstCondition ) {
174180 foreach ($condition in $AstCondition ) {
175- $ScriptBlock.Ast.FindAll ($condition , $true ) |
181+ # Find all of the results.
182+ $ScriptBlock.Ast.FindAll ($condition , ($Recurse -as [bool ])) |
176183 & { process {
177184 $in = $this = $_
178185 [PSCustomObject ][Ordered ]@ {
You can’t perform that action at this time.
0 commit comments