Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for creating new Event Logs #10

Open
craig-martin opened this issue Nov 11, 2015 · 3 comments
Open

Support for creating new Event Logs #10

craig-martin opened this issue Nov 11, 2015 · 3 comments
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.

Comments

@craig-martin
Copy link

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
    }
}
@nebffa
Copy link

nebffa commented Feb 7, 2016

I'd also like this to be implemented.

@kwirkykat kwirkykat added the enhancement The issue is an enhancement request. label Apr 27, 2016
@kwirkykat kwirkykat added the help wanted The issue is up for grabs for anyone in the community. label Aug 19, 2016
@ChrisLGardner
Copy link
Contributor

I've ran into this problem as well and I'm working on a PR to add it.

While looking at using this as a basic layout for implementing it I've discovered a small problem:

  • The test block runs and find that the LogName doesn't exist (or it's sources don't match)
  • The set block runs and creates the LogName with the various sources specified
  • The test block runs again and can't find the LogName because it doesn't have any log entries in it.

So my current solution is that as part of the Set block it will write a log entry for each Source defined. This will populate the log to actually create it but also populate the Source entries allowing further Test blocks to run correctly.

Does anyone see any issues with this? Other than having a few spurious event log entries that might flag in monitoring solutions.

@ChrisLGardner
Copy link
Contributor

Submitted PR #14 which adds this functionality.

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

No branches or pull requests

5 participants