Public/Get-ISComponent.ps1

<#
.SYNOPSIS
    Gets all installed IntelliSearch components
.DESCRIPTION
    The Get-ISComponent cmdlet will list out all installed components, optionally matching the supplied name
.EXAMPLE
    Get-ISComponent -Name "Crawler*"
    This will match all components where the name begins with "Crawler"
.INPUTS
    System.String
.OUTPUTS
    Component
#>

function Get-ISComponent {
    [CmdletBinding(ConfirmImpact='None')]
    [OutputType()]
    param(
        [Parameter(
            Mandatory=$false,
            Position=0,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true
        )]
        [Alias()]
        [String] $Name,

        [Parameter(
            Mandatory=$false,
            Position=1,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true
        )]
        [ValidateScript({ Test-Path $_ -PathType Container -IsValid})]
        [Alias()]
        [String] $InstallDirectory = $IS_Settings.ComponentStore
    )

    begin
    {
        $ComponentDetailRegex = "^(IntelliSearch(?:\.\w+)+)(?:\.)(((?:0|(?:[1-9]\d*)))\.((?:0|(?:[1-9]\d*)))\.((?:0|(?:[1-9]\d*)))(?:-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?)$"
    }

    process
    {   
        Write-Verbose "InstallDirectory: $($InstallDirectory)"

        if (!(Test-Path $InstallDirectory))
        {
            Return
        }

        $InstallDirectoryContents = Get-ChildItem -Path $InstallDirectory -Directory

        foreach ($ComponentDirectory in $InstallDirectoryContents)
        {   
            Write-Verbose "Current component directory: $($ComponentDirectory.FullName)"
            $ComponentDetails = [Regex]::Match($ComponentDirectory.BaseName, $ComponentDetailRegex)
            if ($ComponentDetails.Success -eq $false)
            {
                Write-Verbose "Skipping directory $($ComponentDirectory.FullName) as directory name is not valid"
                continue
            }

            if ($Name -and $ComponentDetails.Value -notlike $Name)
            {
                Write-Verbose "Skipping directory $($ComponentDirectory.FullName) as directory name does not match -Name"
                continue
            }

            $ComponentNupkg = Get-ChildItem -Path $ComponentDirectory.FullName -Recurse | Where-Object {$_.Extension -eq ".nupkg"}
            Write-Verbose "Nupkg count: $($ComponentNupkg.Count)"

            if ($ComponentNupkg.Count -eq 0)
            {
                Write-Verbose "Skipping directory $($ComponentDirectory.FullName) due to it not having a valid nupkg file"
                continue
            }

            [PSCustomObject]@{
                ComponentName      = $ComponentDetails.Value
                ComponentType      = $ComponentDetails.Groups[1].Value
                ComponentVersion   = $ComponentDetails.Groups[2].Value
                ComponentDirectory = $ComponentDirectory.FullName
            }
        }


    }

    end
    {

    }
}