This commit is contained in:
OCram85 2017-09-20 16:38:57 +02:00
parent dcc30c357d
commit f6728a747f
2 changed files with 50 additions and 3 deletions

View File

@ -1,4 +1,52 @@
function Resolve-Dependency {
<#
.SYNOPSIS
Tests defined optional dependencies and returns the result as bool.
.DESCRIPTION
Use this function to test for optional modules. You can use it if you provide functions which needs special
modules but you don't want to make them required.
Place a file called Dependency.json in your module root dir. The default format is:
{
"Version": 0.1,
"Mandatory": {},
"Optional": [
{
"Name": "VMware",
"Modules": [
"VMware.VimAutomation.Core"
]
},
{
"Name": "CiscoUCS",
"Modules": []
}
]
}
.PARAMETER Name
Select the dependency item name you defined in the dependency.json.
.INPUTS
[None]
.OUTPUTS
[bool]
.EXAMPLE
If (-not (Resolve-Dependency -Name 'VMware')) {
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop'
}
.NOTES
File Name : ResolveDependency.ps1
Author : Marco Blessing - marco.blessing@googlemail.com
Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#>
[OutputType([bool])]
[CmdletBinding()]
param (

View File

@ -1,11 +1,10 @@
function Test-Module {
<#
.SYNOPSIS
Internal helper to check optional dependencies.
Tests if the given module exists on the local system.
.DESCRIPTION
Test-Dependency checks if the given module or pssnapin is available on the system. It returns a bool value
So it is possible to use this function in a if condition.
Tests if the given module is installed on the local system. It returns a bool value as result.
.PARAMETER Name
Define a item name you need to test