Hi,
I have an array which contains a load of test results.
I need to cycle from each result and output the value into a CSV file.
The array is created from the output of a pester test:
$TestResults.TestResult
ErrorRecord : Expected: value was {Connection Failed}, but should not have been the same
ParameterizedSuiteName :
Describe : Network Test Status
Parameters : {}
Passed : False
Show : All
FailureMessage : Expected: value was {Connection Failed}, but should not have been the same
Time : 00:00:14.5828361
Name : Connect to Database
Result : Failed
Context :
StackTrace : at , C:\ScriptOutPut\PesterTests\Network_Pester.Test.ps1: line 13
13: $SQLResult | should not be "Connection Failed"
ErrorRecord :
ParameterizedSuiteName :
Describe : Network Test Status
Parameters : {}
Passed : True
Show : All
FailureMessage :
Time : 00:00:03.0306725
Name : Test Connection to Remote Server
Result : Passed
Context :
StackTrace :
ErrorRecord :
ParameterizedSuiteName :
Describe : Network Test Status
Parameters : {}
Passed : True
Show : All
FailureMessage :
Time : 00:00:00.6058733
Name : Copy File
Result : Passed
Context :
StackTrace :
I can run a foreach loop to filter the values i want but only if i use write-host, but obviously this wont export to CSV.
foreach ($Result in $TestResults.TestResult){
write-host $Result.Name, $Result.Time,$Result.Result
}
Output
Connect to Database 00:00:14.5828361 Failed Test Connection to Remote Server 00:00:03.0306725 Passed Copy File 00:00:00.6058733 Passed
Any ideas would be mush appreciated
Thanks
TommyQ