Private/Register-ISPlugins.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<#
.SYNOPSIS Searches a list of directories for valid plugins .DESCRIPTION The Register-ISPlugins cmdlet will traverse a list of directories and output a list of plugin objects. .EXAMPLE Register-ISPlugins -PluginStorePath "C:\Temp" .PARAMETER Plugins A list of directories to load plugins from .INPUTS System.String .OUTPUTS PSObject #> function Register-ISPlugins { param ( # Specifies a path to one or more locations containing plugins [Parameter( Mandatory = $true, Position = 0)] [ValidateNotNullOrEmpty()] [ValidateScript( {Test-Path $_ -IsValid})] [Alias("Path")] [string[]]$PluginStorePath ) $PluginStoreContents = Get-ChildItem -Path $PluginStorePath -Filter "*-plugin.psm1" -File foreach ($PluginFile in $PluginStoreContents) { Write-Verbose "Found plugin $($PluginFile.Name)" $Properties = @{ "Path" = $PluginFile.FullName "Name" = ($PluginFile.Name -replace "([0-9A-Za-z\-]+\-plugin)\.psm1", '$1') } New-Object PSObject -Property $Properties } } |