Skip to content

Preference variables are sometimes considered uninitialized. #142

@imfrancisd

Description

@imfrancisd

If I have this function:

    function get-preference
    {
        [CmdletBinding()]
        Param()

        if (-not $PSBoundParameters.ContainsKey('Verbose')) {
            $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference') -as [System.Management.Automation.ActionPreference]
        }

        $VerbosePreference
    }

the "PSAvoidUninitializedVariable" warning is triggered even though $VerbosePreference will always be initialized.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions