Private/Test-ValidPlugin.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Test-ValidPlugin {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory,Position=0)]
        [string[]]$PluginName,
        [switch]$ThrowOnFail
    )

    $PluginName | ForEach-Object {

        if (-not ($script:Plugins.$_)) {

            if ($ThrowOnFail) {
                throw "$PluginName plugin not found or was invalid."
            } else {
                return $false
            }

        }
    }

    return $true
}