Function/System/Get-F2BConfig.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
<#
.SYNOPSIS
    Function to get current Configuration
.PARAMETER Name
    .
.EXAMPLE
    C:\PS> Get-F2BConfig -ConfigFolder System
.NOTES
    Author : Thomas ILLIET
    Date : 2018-02-15
    Last Update : 2018-02-15
#>

function Get-F2BConfig(){
    Param(
        [Parameter(Mandatory=$true)]
        [ValidateSet('System','Module')]
        [String]$ConfigFolder
    )
    Try {
        $Items = Get-Item "HKLM:\SOFTWARE\Fail2Ban\Config\$ConfigFolder" -ErrorAction Stop
        if($Items.Property -ne $null) {
            $hashtable = @{}
            foreach( $Item in $Items.Property ){
                $hashtable[$Item] = (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Fail2Ban\Config\$ConfigFolder" -Name $Item)
            }
            return $hashtable
        }
    } Catch {
        write-error "Unable to get configuration : $_"
    }
}