I'm sure it's a silly problem but I can't seem to add element to array in function.
PowerShell 2.0
$jobResult = @()
function Gather-JobResults {
Param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string] $message
)
begin {}
process {
$jobResult += ([string]::Format("{0} - {1}", (Get-Date -f "yyyy-MM-dd HH:mm:ss"), $message))
Write-Host "--- Status jobResult ---> $jobResult"
}
end{}
}
Gather-JobResults("zabaaa")
Gather-JobResults("zaaaauuuuuuuul")
Gather-JobResults("winkoooo")
$jobResult
The $jobResult
is empty after I call 3x Gather-JobResults
, how can I fix this ?
Thanks for any answers