Last active
October 22, 2016 18:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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