impact/Install-ImpactEventLog.ps1

function Install-ImpactEventLog {

$ImpactModule = $ImpactModule = (Get-Module -Name ImpactPartnership-PS -ListAvailable | Sort Version -Descending | Select -First 1)
$ImpactEventSources = Get-ChildItem $ImpactModule.ModuleBase -Recurse -File -Filter *.ps1 | Select -Property BaseName

If (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    If (![System.Diagnostics.EventLog]::Exists('Impact-Partnership')) {
        New-EventLog -LogName 'Impact-Partnership' -Source ImpactPartnership-PS
        Write-EventLog -log Impact-Partnership -Source ImpactPartnership-PS -EntryType Information -EventId 0 -Message "ImpactPartnership-PS log has been created."
        Write-EventLog -log Impact-Partnership -Source ImpactPartnership-PS -EntryType Information -EventID 1 -Message "ImpactPartnership-PS Module Version: $($ImpactModule.Version.ToString())"
    } else {
        Write-EventLog -log Impact-Partnership -Source ImpactPartnership-PS -EntryType Information -EventID 1 -Message "ImpactPartnership-PS Module Version: $($ImpactModule.Version.ToString())"
    }
    foreach ($ImpactSource in $ImpactEventSources.BaseName) {
            if (![System.Diagnostics.EventLog]::SourceExists($ImpactSource)) {
                New-EventLog -LogName 'Impact-Partnership' -Source "ImpactPartnership-PS_$ImpactSource"
                Write-EventLog -LogName 'Impact-Partnership' -Source "ImpactPartnership-PS_$ImpactSource" -EntryType Info -EventID 2 -Message "Event Source $ImpactSource Registered"
                }
            }
} else {
Write-Host "This Impact Partnership command requires elevation." -ForegroundColor Red
}
}