Locate specific commands, words, or logic in a SEA OF SCRIPTS

Scenario: I have 300 scripts in a directory, but I am not sure which script is running a specific command. Using the following, you can quickly parse through all of your scripts and locate the string ( Command | Word | Phrase ) to see which script has it.

Solution: Scritplet:


get-childitem C:\scripts\*.ps1 -Recurse | Select -ExpandProperty Fullname | %{
        $fn = $_
            $str | %{
                $s = $_
                $D = get-content $fn | Select-String $s
                If($D -ne $Null){
                    Write-Host "
                    Found String in File:  $fn" -ForegroundColor Cyan
                    } #ENdIF
            }##end $Str loop
 }#End get-childitem loop


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: