Public/Providers.ps1
Function Import-TMCProvider { [CmdletBinding()] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] [String]$Provider, [Parameter(Mandatory = $false)] [Switch]$Force ) begin { } process { ## Get the PS module Root folder $TMProviderModuleName = 'TMConsole.Provider.' + ($Provider -replace ' - ', '.' -replace ' ', '.') ## Get the list of installed provider modules if ($Force) { $InstalledProviderModules = @((Get-Module -Name 'TMConsole.Provider.*' -ListAvailable).Name) } else { $InstalledProviderModules = Get-TMConsoleSetting -Name 'InstalledProviderModules' } ## If the Module is not installed if ($TMProviderModuleName -in $InstalledProviderModules) { ## Import the module . Import-Module $TMProviderModuleName -ErrorAction 'SilentlyContinue' } } end { } } |