Hello, I hope one of you may be able to help me record the status of some of the functions.
So I essentially have the function test do something like add a user, depending on the result ie exception or nothing then the script updates the value of $Test_result under the $result object.
However when running $print_results the output is just the array and empty strings.
Should I just do $result.Test_Result = “success” to update it?
Function print_results{
Write-Host $result
}
function Test{
Try{
Some code
$Script:Test_Result = “Success”
}
Catch{
Some code
$Script:Test_Result = “Failure”
}
}
$result = [PSCustomObject]@{‘Test’ = $Test_Result;}