Skip to content

Script analyzer warns about unused variables when variable is used in Invoke-Command #825

Description

@DanrwAU

Hi Guys,

Script Analyzer is flagging a few variables as not used anywhere in the script.

These variables are only used during an Invoke-Command line when is calling them like below

Invoke-Command -Session $S -ScriptBlock {$VMDet = Get-VM $VM}
$VMDetails = Invoke-Command -Session $S -ScriptBlock {$VMDet}

Script analyzer is throwing file: '
message: 'The variable 'VMDet' is assigned but never used. (PSUseDeclaredVarsMoreThanAssignments)'
at: '665,62'
source: 'PSScriptAnalyzer'

Cheers

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions