Private/Test-GetModule.ps1
<#
.SYNOPSIS Checks, whether specified module is loaded. #> function Test-GetModule { [CmdLetBinding()] [OutputType([bool])] param ( [Parameter(Mandatory = $true, HelpMessage = "Exact name of the mmodule")] [string] $Name, [Parameter(Mandatory = $false, HelpMessage = "Minimum required module version")] [Version] $RequiredVersion ) $ErrorActionPreference = 'Stop' $module = Get-Module -Name $Name -ErrorAction SilentlyContinue if([string]::IsNullOrEmpty($module) -or [string]::IsNullOrEmpty($module.Version)) { return $false } if([string]::IsNullOrEmpty($RequiredVersion)) { return $true } if([Version] $module.Version -ge $RequiredVersion) { return $true } else { return $false } } |