Skip to content

Support for creating new Event Logs #10

@craig-martin

Description

@craig-martin

Would be great if I could use this resource to create new event logs and event sources.
For example today I would call New-EventLog like this to get this done:

### Create log and source
New-EventLog -LogName BigLog -Source TheHorsesMouth

My lame workaround is to use the Script resource:

Script MyEventLog
{
    GetScript  = {
        return @{LogName='MyEventLog'}
    }
    TestScript = {
        try{
            Write-Verbose "Getting EventLog 'MyEventLog' with Source 'MySource'"
            Get-EventLog -LogName MyEventLog -Source MySource -Newest 1 | Out-Null
            return $true
        }
        catch{
            Write-Warning 'Log not found'
            return $false
        }
    }
    SetScript  = {
        Write-Verbose "Creating EventLog 'MyEventLog' with Source 'MySource'"
        New-EventLog -LogName MyEventLog -Source MySource -Verbose
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue is an enhancement request.in progressThe issue is being actively worked on by someone.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions