Both, the $ErrorActionPreferencevariable and -ErrorActionthe cmdlet argument should determine the behavior for non-termination errors .
$ErrorActionPreference
-ErrorAction
Since the variable is global and the argument is specific to calling cmdlet, I expect the argument to override the variable. In fact, I can’t find a situation where -ErrorActiondoing anything at all.
$expression = 'Write-Error "non-terminating error"' # No exception $ErrorActionPreference = 'Continue' Invoke-Expression -Command $expression # Exception $ErrorActionPreference = 'Stop' Invoke-Expression -Command $expression # No exception, why? $ErrorActionPreference = 'Continue' Invoke-Expression -Command $expression -ErrorAction Stop # Exception, why? $ErrorActionPreference = 'Stop' Invoke-Expression -Command $expression -ErrorAction Continue
PS - I found this question , but is more focused on the corresponding problem, rather than on priority.
-ErrorAction , , . Invoke-Expression (iex) , , . /.
Invoke-Expression (iex)
OP, -ErrorAction Write-Error, , , iex.
Write-Error
iex
Source: https://habr.com/ru/post/1627952/More articles:Android: do I really need a custom Firebase check? - androidHow to fill a Mysql docker container while building another container? - dockerline simplification algorithm: Visvalingam vs Douglas-Peucker - algorithmOptional self-rotate in Elasticsearch - phpБолее умный способ генерации матрицы нулей и единиц в Matlab - optimizationHow to clear pre tag in html - javascriptpowershell $ erroractionpreference overrides -erroraction - powershellhow to confuse or indicate richlightbox silverlight text? - c #SQL - update now () data with date only - dateCumulocity Event Language - Calling an External API - cumulocityAll Articles