Created
March 28, 2014 07:40
-
-
Save altrive/9827349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-LocalVariable | |
{ | |
[CmdletBinding()] | |
param ( | |
) | |
#define buildin variables | |
$builtinVariable = [PSObject].Assembly.GetType('System.Management.Automation.SpecialVariables').GetFields('NonPublic,Static') | where FieldType -eq ([string]) | foreach GetValue($null) | |
$builtinVariable += @("FormatEnumerationLimit", "MaximumAliasCount", "MaximumDriveCount", "MaximumErrorCount", "MaximumFunctionCount", "MaximumHistoryCount", "MaximumVariableCount", "profile", "psISE", "PSSessionOption", "PSUICulture", "psUnsupportedConsoleApplications", "PSVersionTable", "startupFiles") | |
#Get local variable(If use this function inside PSModule, set -Scope 2 instead ) | |
$variables = Get-Variable -Scope 1 | where Name -notin $builtinVariable | select Name,Value | |
return $variables | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment