Summary: Find the number of variables in-scope in your function.
How can I see how many variables are available in-scope and out-of-scope in my Windows PowerShell function?
Use the Get-Variable cmdlet, the Count property, and the –Scope parameter:
All variables
PS C:\> function myvar {(Get-Variable).count}
PS C:\> myvar
49
Variables in-scope
PS C:\> function myvar {(Get-Variable -Scope 0).count}
PS C:\> myvar
25
0 comments