Public/Get-ISCrawler.ps1

#requires -version 4

function ModuleRoot { $MyInvocation.ScriptName | Split-Path -Parent}

. $PSScriptRoot\New-ISCrawler.ps1

<#
.SYNOPSIS
    Gets configured ICD crawlers
.DESCRIPTION
    The Get-ISCrawler cmdlet parses a CrawlerConfig.xml file and returns objects representing the configured crawlers.
.EXAMPLE
    Get-ISCrawler "C:\Program Files\IntelliSearch\ESP-1\Config\CrawlerConfig.xml"
.INPUTS
    System.String
.OUTPUTS
    Crawler
#>

function Get-ISCrawler {
    [CmdletBinding(DefaultParameterSetName='Parameter Set 1',
                   SupportsShouldProcess=$false,
                   PositionalBinding=$false,
                   ConfirmImpact='None')]
    [Alias()]
    Param (
        # The path to the CrawlerConfig.xml file
        [Parameter(Mandatory=$true,
                   Position=0,
                   ValueFromPipeline=$true,
                   ValueFromPipelineByPropertyName=$true,
                   ValueFromRemainingArguments=$false, 
                   ParameterSetName='Parameter Set 1')]
        [ValidateNotNull()]
        [ValidateNotNullOrEmpty()]
        [Alias()] 
        [string] $Path
    )

    process {
        $Path = Resolve-Path $Path

        $xml = New-Object XML
        $xml.Load($Path)

        # Create XML namespaces for use when searching for the correct node to remove.
        # Prepend "ns:" to the node to search for
        $XmlNamespace = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
        $XmlNamespace.AddNamespace("ns", $xml.DocumentElement.NamespaceURI)

        $Nodes = $xml.SelectNodes("//ns:Crawler", $XmlNamespace)
        
        # Removing the namespace for consistency
        $XmlNamespace.RemoveNamespace("ns", $xml.NamespaceURI)

        foreach ($XmlCrawler in $Nodes) {
            Write-Verbose "Processing crawler: $($XmlCrawler.InstanceId)"
            New-ISCrawler -XmlInput $XmlCrawler
        }
    }
}