-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPester_EV_Script.ps1
More file actions
68 lines (59 loc) · 1.66 KB
/
Pester_EV_Script.ps1
File metadata and controls
68 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<#
.SYNOPSIS
Event logging
.DESCRIPTION
Event logging for pester test.
.PARAMETER
N/A
.INPUTS
JSON file contains the inputs.
.OUTPUTS
Event Log
.NOTES
Version: 7.4.3
Author: Paul Skeie
Creation Date: 12/01/19
Purpose/Change: Event Logging
.EXAMPLE
PS Invoke-Pester .\PesterTests.ps1
#>
function Invoke-NCRPesterTest {
[cmdletbinding()]
param (
[String] $eventLogName = 'BVT',
[String] $eventSource = 'Pester Test',
[Int32] $eventErrorId = 4000,
[Int32] $eventInfoId = 1000,
[ValidateSet('Simple','Comprehensive')]
[String] $TestType = 'Simple'
)
# Add the Event Source if it doesn't exist
If ([System.Diagnostics.EventLog]::SourceExists($eventSource) -eq $False) {
New-EventLog -LogName $eventLogName -Source $eventSource
}
# Execute the tests
$tests = Invoke-OperationValidation -ModuleName NCRPesterTest -TestType $TestType
foreach ($test in $tests) {
# Add the tests to the Event Log
if ($test | Where-Object -Property Result -EQ -Value 'Failed') {
Write-EventLog `
-LogName $eventLogName `
-Source $eventSource `
-EntryType Error `
-Message $test.Name `
-EventId $eventErrorId `
-Category 0
$eventId++
}
elseif ($test | Where-Object -Property Result -EQ -Value 'Passed') {
Write-EventLog `
-LogName $eventLogName `
-Source $eventSource `
-EntryType Information `
-Message $test.Name `
-EventId $eventInfoId `
-Category 0
$eventId++
}
}
}