Private/Get-HPSSecurityPolicyParameters.ps1

Function Get-HPSSecurityPolicyParameters {

    <#
        .SYNOPSIS
        Get current module path

        .DESCRIPTION
        Simple function to get module path with $ModulePath, and allow to makes it easy to test the project functions.

        .PARAMETER BoundParameters
        n/a

        .PARAMETER ParameterSetName
        n/a

        .PARAMETER ConfigName
        n/a

        .EXAMPLE
        Get-HPSModulePath

        .OUTPUTS
        System.String

        .LINK
        https://hardening.thomas-illiet.fr/Private/Get-HPSSecurityPolicyParameters/

        .LINK
        https://github.com/thomas-illiet/HardenedPS/blob/stable/Src/Private/Get-HPSSecurityPolicyParameters.ps1

        .NOTES
        - File Name : Get-HPSSecurityPolicyParameters.ps1
        - Author : Thomas ILLIET
    #>


    [CmdletBinding( HelpUri = "https://hardening.thomas-illiet.fr/Private/Get-HPSSecurityPolicyParameters/" )]
    [OutputType( [System.Object] )]
    Param(
        [Parameter( Mandatory = $True )]
        [System.Object]
        $BoundParameters,

        [Parameter( Mandatory = $True )]
        [System.Object]
        $ParameterSetName,

        [Parameter( Mandatory = $True )]
        [System.String]
        $ConfigName
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    process {
        if( $ParameterSetName -eq 'Preset' ) {
            $Config = Get-HPSConfig -Name $ConfigName
            if( $Config.Preset.$Preset ) {
                $BoundParameters = $Config.preset.($Preset)
            } else {
                throw 'Preset not found'
            }
        }
        else {
            # Delete unnecessary variables
            $UnnecessaryVariables = @( 'Verbose', 'Debug', 'Detail', 'Cache' )
            foreach( $UnnecessaryVariable in $UnnecessaryVariables ){
                $BoundParameters.Remove($UnnecessaryVariable) | Out-Null
            }
        }

        $Parameters = @()
        foreach( $BoundParameter in $BoundParameters.GetEnumerator() ) {
            Write-Verbose $BoundParameter.Key
            $Parameters += [PSCustomObject]@{
                Name = $BoundParameter.Key
                Value = $BoundParameter.Value
            }
        }
        return $Parameters
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

}