DSCResources/cRegisterDSCTrigger/cRegisterDSCTrigger.psm1


function Get-TargetResource {
    [CmdletBinding()]
    [OutputType([Hashtable])]
    param([Parameter(Mandatory=$true)]
[string]
$Name)

    @{}
}

function Set-TargetResource {
    [CmdletBinding()]
    
    param([Parameter()]
[string]
$Configuration,
    [Parameter()]
[string]
$EventFilter,
    [Parameter(Mandatory=$true)]
[string]
$Name,
    [Parameter()]
[switch]
$Force,
    [Parameter()]
[string]
$EventNamespace)

    $splat = @{}
$setCommand = $executionContext.SessionState.InvokeCommand.GetCommand('Register-DSCTrigger', 'all')
if ($psBoundParameters.ContainsKey('Configuration')) {
    $splat['Configuration'] = [ScriptBlock]::Create($Configuration)
}
if ($psBoundParameters.ContainsKey('EventNamespace')) {
    $splat['EventNamespace'] = $EventNamespace
}
if ($psBoundParameters.ContainsKey('Name')) {
    $splat['Name'] = $Name
}
if ($psBoundParameters.ContainsKey('Force')) {
    $splat['Force'] = $Force
}
if ($psBoundParameters.ContainsKey('EventFilter')) {
    $splat['EventFilter'] = $EventFilter
}

if (-not $splat.ContainsKey('Force')) {
$splat.Force = $True
}
Register-DSCTrigger @splat | Out-Null
}

function Test-TargetResource {
    [CmdletBinding()]
    [OutputType([bool])]
    param([Parameter()]
[string]
$Configuration,
    [Parameter()]
[string]
$EventFilter,
    [Parameter(Mandatory=$true)]
[string]
$Name,
    [Parameter()]
[switch]
$Force,
    [Parameter()]
[string]
$EventNamespace)

    
    -not ((Get-DSCTrigger | Where-Object { $_.Name -eq $Name }) -as [bool])

}

Export-ModuleMember -Function Get-TargetResource, Set-TargetResource, Test-TargetResource