PowerTip: Use PowerShell to Look Up Variable Values

Doctor Scripto

Dr Scripto

Summary: Look up variable values in the caller’s scope.

Hey, Scripting Guy! Question I’m writing a Windows PowerShell advanced function in a script module. How can I look up the value of
          variables set in my caller’s scope?

Hey, Scripting Guy! Answer Use the $PSCmdlet.GetVariableValue() method:


param ( )

$variableValue = $PSCmdlet.GetVariableValue(‘variableName’)

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   


    Leave a comment