en-US/about_SpecModuleImporter.help.txt
TOPIC
about_SpecModuleImporter SHORT DESCRIPTION A module that assists with the importing of PowerShell modules from the PSGallery LONG DESCRIPTION This module can assist with the installation and importing of modules from the PSGallery. - You are able to specify a particular verions number to install, or you can install the latest version. - You are able to import as specific module version even though multiple versions are installed. EXAMPLES $moduleImporterRequiredVersion = '1.0.2' # Check if the module is already loaded $installedModule = Get-Module -Name 'SpecModuleImporter' -ListAvailable | Where-Object { $_.Version -eq $moduleImporterRequiredVersion } # Module is not installed or wrong version, so install it from the PowerShell Gallery if ($installedModule -eq $null) { Write-Host "Module 'SpecModuleImporter' is either not installed or is not at the correct version" Write-Host "Installing required version: $moduleImporterRequiredVersion" Install-Module -Name "SpecModuleImporter" -RequiredVersion $moduleImporterRequiredVersion -Force Write-Host "Module 'SpecModuleImporter' has been installed." } else { Write-Host "Module 'SpecModuleImporter' is already installed and at the correct version ($moduleImporterRequiredVersion)" } #import the module at the required version Write-Host "Importing Module: SpecModuleInstaller ($moduleImporterRequiredVersion)" try { Remove-Module specmoduleimporter -ea Stop Import-Module SpecModuleImporter -RequiredVersion $moduleImporterRequiredVersion -Force } catch { Import-Module SpecModuleImporter -RequiredVersion $moduleImporterRequiredVersion -Force } # Install a specific version of a module. (If you want the latest version set RequiredVersion = "") $Modules = @( @{ moduleName = 'SpecBaseModule' requiredVersion = "1.0.2" }, @{ moduleName = 'Az.Accounts' requiredVersion = '2.10.2' } ) #install modules if required $modules | % { Install-SpecPowerShellModule -Module $_.moduleName -RequiredVersion $_.requiredVersion -Scope CurrentUser -Verbose} #Import the specified version of the module $modules | % { Import-SpecPowerShellModule -Module $_.modulename -RequiredVersion $_.requiredversion -Verbose } KEYWORDS SEE ALSO |