Private/Check-GlpiToolsPluginExist.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#
.SYNOPSIS
    Function that check if GLPI Plugin is Enable in GLPI
.DESCRIPTION
    Function that check if GLPI Plugin is Enable, if not, will throw error, if yes, will continue fuction execution
.EXAMPLE
    PS C:\> Check-GlpiToolsPluginExist -InvocationCommand "Get-GlpiToolsFusionInventoryAgent"
    Example will return True if plugin is Enabled in GLPI or False if not. \
.PARAMETER InvocationCommand
    Parameter which is used to provide plugin name to check in function
.INPUTS
    InvocationCommand
.OUTPUTS
    Boolean, True if Plugin is Enabled, False if not
.NOTES
    PSP 04/2019
#>


function Check-GlpiToolsPluginExist {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $false)]
        [string]$InvocationCommand
    )
    
    begin {

        $GlpiAvailablePlugins = Get-GlpiToolsPlugins | Where-Object { $_.State -eq "Enabled" }

    }
    
    process {

        foreach ($Plugin in $GlpiAvailablePlugins) {
            $name = $Plugin.name -replace " ",""
            if ($InvocationCommand -match $name) {
                $check = " "
            } else {
                
            }
        }

        if ($check) {
            return $true
        } else {
            return $false
        }
    }
    
    end {
        
    }
}