The following code produces errors, I set EA to “SilentlyContinue” to not show errors but instead save them to ErrorVariable:
$UpdateParams = @{
ErrorVariable = "UpdateError"
ErrorAction = "SilentlyContinue"
}
# This will surely generate errors in Windows PowerShell
Update-Help @UpdateParams
# Show errors manually: (doesn't work)
$UpdateParams["ErrorVariable"]
Output is just a variable name:
UpdateError
Expected output:
The actual errors
I want to capture errors without displaying them in this code but as you can see it doesn’t work