public/Invoke-Vexa.ps1

function Invoke-Vexa {
    [Alias("vexa")]
    [CmdLetBinding()]
    param (
        [Parameter(
            Mandatory = $true
        )]
        [string[]] $Path,

        [Parameter(
            Mandatory = $false
        )]
        [ValidateSet("All", "VIServer", "Datacenter",
                     "HostSystem", "ClusterComputeResource", "AdvancedSettings")]
        [string[]] $Test = "All",

        [Parameter(
            Mandatory = $false
        )]
        [switch] $IncludeAdvSettings = [switch]::present,

        [Parameter()]
        [hashtable] $Filter,

        [Parameter(
            Mandatory = $false
        )]
        [ValidateSet("All", "Context", "Default",
                     "Describe", "Failed", "Fails",
                     "Header", "Inconclusive", "None",
                     "Passed", "Pending", "Skipped", "Summary")]
        [string[]] $Show = "All"
    )

    Write-VexaStart

    foreach ($File in $Path) {
        $Prev = Import-VexaInventory -Path $File
        $Cur = New-VexaInventory -Server $Prev.VIServer.Name
        $global:VexaData = @{
            Inventories = @{
                Prev = $Prev
                Cur = $Cur
            }
        }

        if ($Filter) {
            Write-Warning "The -Filter parameter is not yet implemented. It will be implemented in a later release."
            # Invoke-VexaFilter -Filter $Filter
        }

        $PesterParams = @{
            Script = @(
                @{
                    Path = "$PSScriptRoot\..\tests\VIServer.Tests.ps1"
                    Parameters = @{
                        PrevInventory = $global:VexaData.Inventories.Prev
                        CurInventory = $global:VexaData.Inventories.Cur
                        Test = $Test
                        IncludeAdvSettings = $IncludeAdvSettings
                        Filter = $Filter
                    }
                }
            )
            Show = $Show
        }

        # Override Pester header with custom Vexa one.
        $global:VexaData.VexaPesterStart = $null
        $global:VexaData.VexaStartNull = Get-Content function:Write-VexaStartNull
        & (Get-Module Pester) {
            $global:VexaData.VexaPesterStart = Get-Content function:Write-PesterStart
            Set-Item function:Write-PesterStart -Value $global:VexaData.VexaStartNull
        }

        Invoke-Pester @PesterParams

        # Reset the Pester header function to its original value.
        & (Get-Module Pester) {
            Set-Item function:Write-PesterStart -Value $global:VexaData.VexaPesterStart
        }

        Write-VexaTotals -Test $Test -Filter $Filter
        Remove-Variable -Name "VexaData" -Scope "Global" -Confirm:$false
    }
}