SearchScript.psd1

#
# Module manifest for module 'SearchScript'
#
# Generated by: James Brundage
#
# Generated on: 12/12/2025
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'SearchScript.psm1'

# Version number of this module.
ModuleVersion = '0.1.2'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '1d657c62-a561-4ea1-8b56-3e7679bbad79'

# Author of this module
Author = 'James Brundage'

# Company or vendor of this module
CompanyName = 'Start Automating'

# Copyright statement for this module
Copyright = '2025-2026 Start Automating'

# Description of the functionality provided by this module
Description = 'Search PowerShell Scripts'

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'SearchScript','Search-Script'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.

# Variables to export from this module
VariablesToExport = 'SearchScript'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'srsb', 'srScript'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

    PSData = @{

        # Tags applied to this module. These help with module discovery in online galleries.
        Tags = @('SearchScript','Search','Cybersecurity')

        # A URL to the license for this module.
        LicenseUri = 'https://github.com/StartAutomating/SearchScript/blob/main/LICENSE'

        # A URL to the main website for this project.
        ProjectUri = 'https://github.com/StartAutomating/SearchScript/'

        # A URL to an icon representing this module.
        # IconUri = ''

        # ReleaseNotes of this module
        ReleaseNotes = @'

## SearchScript 0.1.2

* `Search-Script -For ([type])` checks static types (#14)
* `Search-Script -For ([string])` checks `Value` (#15)

---

Additional release notes in [CHANGELOG](https://github.com/StartAutomating/SearchScript/blob/main/CHANGELOG.md)

'@


        PSIntro = @'
## Introduction

Every once in a while, we've got to search our scripts, often to make a particular update.

Sadly, we're often falling back on Select-String to do this.

This isn't ideal, because this means we lose the context around our scripts.

So why not make a quick tool to search PowerShell ScriptBlocks using the Abstract Syntax Tree?

## Examples

Let's start simple. As a general rule, we don't want to use Invoke-Expression in our scripts.

We can find any matching part of the syntax tree:

~~~PowerShell
{
    iex "'I could do anything'"
}, {
    Invoke-Expression "IsBad, ok"
}, {
    "this is fine"
} |
    Search-Script -For "^(iex|Invoke-Expression)"
~~~

Suppose we want to update any scripts that use Invoke-WebRequest,
in order to address [CVE-2025-54100](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-54100).

We can use a little bit of Regex to identify them,
but it gets a _lot_ trickier to write a pattern that will find if it's already fixed or not.

If we could just see that they use -UseBasicParsing, then it's already been fixed.

This little script helps us tell the difference:

~~~PowerShell
{
    Invoke-WebRequest -Url $NotOK # not yet fixed
},{
    Invoke-WebRequest -Url $OK -UseBasicParsing # already fixed
} |
    Search-Script -For {
        param($ast)
        if (-not $ast.CommandElements -or (
            $ast.CommandElements[0] -notmatch 'Invoke-WebRequest|curl|iwr'
        )) {
            return $false
        }
        if (-not ($ast.CommandElements -match '-UseBasicParsing')) { return $true }
        return $false
    }
~~~
'@


        # Prerelease string of this module
        # Prerelease = ''

        # Flag to indicate whether the module requires explicit user acceptance for install/update/save
        # RequireLicenseAcceptance = $false

        # External dependent modules of this module
        # ExternalModuleDependencies = @()

    } # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}