PowerTip: Use PowerShell to Look Up Variable Values

PowerTip: Use PowerShell to Look Up Variable Values

  • Comments 2
  • Likes

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:

[CmdletBinding()]

param ( )

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment