I\'ve been giving PowerShell (v3.0) a shot for the first time today, and became enormously frustrated with the strange way some of its error-handling concepts are implemented.>
Since you're running V3, you also have the option of using $PSDefaultParameterValues:
$PSDefaultParameterValues += @{'New-RegKey:ErrorAction' = 'Stop'}
Normally that will change it in the global scope. If you want to isolate it to just the local or script scope, you can initialize a new one in the local scope first:
$PSDefaultParameterValues = @{}
$PSDefaultParameterValues += @{'New-RegKey:ErrorAction' = 'Stop'}
If you want to inherit what's already in the parent scope and then add to it for the local scope:
$PSDefaultParameterValues = $PSDefaultParameterValues.clone()
$PSDefaultParameterValues += @{'New-RegKey:ErrorAction' = 'Stop'}
To set the default ErrorAction for all cmdlets, not just New-RegKey, specify '*:ErrorAction'
instead of 'New-RegKey:ErrorAction'
in the code above.