Public/Install-CheckIDPasswordAgentLogging.ps1

<#
.DESCRIPTION
    Creates the "CheckIDPasswordAgent" event log source in the Application event log, which is required for logging events during the execution of the module's functions. Must be run once as administrator. Does nothing if the source already exists.

.SYNOPSIS
    Installs the event log source for CheckIDPasswordAgent.

.EXAMPLE
    # Run as administrator
    Install-CheckIDPasswordAgentLogging
#>

function Install-CheckIDPasswordAgentLogging {
    [CmdletBinding()]

    Param()

    Process {
        if ([System.Diagnostics.EventLog]::SourceExists($Script:EventLogSource)) {
            Write-Verbose "Event log source '$($Script:EventLogSource)' already exists."
            return
        }

        [System.Diagnostics.EventLog]::CreateEventSource($Script:EventLogSource, "Application")
        Write-Verbose "Created event log source '$($Script:EventLogSource)' in the Application event log."
    }
}