Functions/ModuleManagement/Import-BcModule.ps1

function Import-BcModule
{
    [CmdletBinding(DefaultParameterSetName='ServerInstance')]
    Param
    ( 
        # Gets the modules compatible with the supplied serverinstance.
        [Parameter(ParameterSetName='ServerInstance', Mandatory = $true)]
        [string] $ServerInstance,    
        
        # Gets the modules compatible with the supplied BcVersion. E.g. 'bc15' or 'bc13'.
        [Parameter(ParameterSetName='BcVersion', Mandatory = $true)]
        [string] $BcVersion,
        
        # Gets the modules compatible with the supplied BC Service installation path.
        [Parameter(ParameterSetName='BcInstallationPath', Mandatory = $true)]
        [string] $BcInstallationPath,

        [switch] $ManagementModule,

        [switch] $AppManagementModule,

        [switch] $AppToolsModule,

        [switch] $Force
    )
    $arguments =@{
        'ManagementModule' = $ManagementModule
        'AppManagementModule' = $AppManagementModule
        'AppToolsModule' = $AppToolsModule
    }
    if($BcVersion){
        $arguments += @{
            'BcVersion' = $BcVersion
        }
    }
    if($ServerInstance){
        $arguments += @{
            'ServerInstance' = $ServerInstance
        }
    }
    if($BcInstallationPath){
        $arguments += @{
            'BcInstallationPath' = $BcInstallationPath
        }
    }

    $modules = Get-BcModule @arguments
    
    $modules | Import-Module -DisableNameChecking -Global -Force:$Force
}

Export-ModuleMember -Function Import-BcModule