Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Last active Oct 22, 2016
Embed
What would you like to do?
PowerShell Module for Invoking the ValidateDNS Operation Validation Framework tests and raising Events
function Invoke-ValidateDNS {
[cmdletbinding()]
param (
[String] $EventSource = 'ValidateDNS',
[Int32] $EventId = 10000,
[ValidateSet('Simple','Comprehensive')]
[String] $TestType = 'Simple'
)
# Edit these settings
# Add the Event Source if it doesn't exist
if (-not [system.diagnostics.eventlog]::SourceExists($EventSource)) {
[system.diagnostics.EventLog]::CreateEventSource($EventSource, 'Application')
} # if
# Execute the tests
$FailedTests = Invoke-OperationValidation -ModuleName ValidateDNS -TestType $TestType |
Where-Object -Property Result -EQ -Value 'Failed'
# Add the Failed tests to the Event Log
foreach ($FailedTest in $FailedTests) {
Write-EventLog `
-LogName Application `
-Source $EventSource `
-EntryType Error `
-Message $FailedTest.Name `
-EventId $EventId `
-Category 0
$EventId++
} # foreach
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment