-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathStart-C4bVerification.ps1
40 lines (38 loc) · 1.72 KB
/
Start-C4bVerification.ps1
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
#requires -modules C4B-Environment
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[String]
$Fqdn
)
process {
if (-not (Get-Module Pester -ListAvailable).Where{$_.Version -gt "5.0"}) {
Write-Host "Installing Pester 5 to run validation tests"
$chocoArgs = @('install', 'pester', "--source='ChocolateyInternal'", '-y', '--no-progress', '--source="https://community.chocolatey.org/api/v2/"')
& Invoke-Choco @chocoArgs
}
$files = (Get-ChildItem C:\choco-setup\files\tests\ -Recurse -Filter *.ps1).Fullname
Write-Host "Configuring Pester to complete verification tests"
$containers = $files | Foreach-Object { New-PesterContainer -Path $_ -Data @{ Fqdn = $Fqdn } }
$configuration = [PesterConfiguration]@{
Run = @{
Container = $Containers
Passthru = $true
}
Output = @{
Verbosity = 'Detailed'
}
TestResult = @{
Enabled = $true
OutputFormat = 'NUnitXml'
OutputPath = 'C:\choco-setup\test-results\verification.results.xml'
}
}
$results = Invoke-Pester -Configuration $configuration
if ($results.FailedCount -gt 0) {
Compress-Archive -Path C:\choco-setup\test-results\verification.results.xml -DestinationPath "C:\choco-setup\files\support_archive.zip"
Get-ChildItem C:\choco-setup\logs -Recurse -Include *.log,*.txt | Foreach-Object { Compress-Archive -Path $_.FullName -Update -DestinationPath "C:\choco-setup\files\support_archive.zip" }
Write-Host "Logs have been collected into 'C:\choco-setup\files\support_archive.zip'."
Write-Host "Please submit this archive to [email protected] so our team can assist you."
}
}