Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Last active October 22, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlagueHO/5ce7d041fcde3e0702c63729ca6567d1 to your computer and use it in GitHub Desktop.
Save PlagueHO/5ce7d041fcde3e0702c63729ca6567d1 to your computer and use it in GitHub Desktop.
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