I came across this private error variable example recently.
#hiding errors:
$ErrorActionPreference = 'SilentlyContinue'
#telling all cmdlets to use a private variable for error logging:
$PSDefaultParameterValues.Add('*:ErrorVariable', '+myErrors')
#initializing the variable:
$myErrors = $null
#do stuff:
Stop-Service -Name Spooler
dir c:\gibtsnichtabcs
#check errors at end USING PRIVATE VARIABLE:
$myErrors
I just want to understand the $PSDefaultParameterValues.Add line above as to how prepending + to the myErrors variable name makes it cumulative. Thanks.