79604982

Date: 2025-05-03 18:17:38
Score: 0.5
Natty:
Report link

I know that you said that you don't want to modify functions, but I though my solution might be helpful to someone else in the future, so I will add it here :)

I came up with following approach to get common parameter value in function:

$ErrorAction = $PSCmdlet.MyInvocation.BoundParameters.ErrorAction
if ($null -eq $ErrorAction) {
    $ErrorAction = $ErrorActionPreference
}

Then I have applied it to related function call:

Install-PackageProvider -Name $ProviderName -Force:$Force -ErrorAction $ErrorAction

Here is related commit in my repository:

https://github.com/gucu112/Gucu112.Powershell/commit/12969ac0657500bc992cb8d9669cefb52e99b0b7

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Gucu112