From 46416dc4af126b7b0a4304a5bd822c267a83be4b Mon Sep 17 00:00:00 2001 From: James Brundage <@github.com> Date: Fri, 28 Jun 2024 21:10:52 -0700 Subject: [PATCH] feat: Namespace.get_Variable ( Fixes #1144 ) --- Types/Namespace/get_Variable.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Types/Namespace/get_Variable.ps1 diff --git a/Types/Namespace/get_Variable.ps1 b/Types/Namespace/get_Variable.ps1 new file mode 100644 index 000000000..9d872dcb4 --- /dev/null +++ b/Types/Namespace/get_Variable.ps1 @@ -0,0 +1,19 @@ +<# +.SYNOPSIS + Gets the variables in the namespace. +.DESCRIPTION + Gets all the variables in the namespace. + + These are all the variables where the name matches the pattern of the namespace, + or the `.Value.pstypenames` match the pattern of the namespace. +#> + +foreach ($variable in Get-ChildItem variable:) { + if ($variable.Name -in 'this','_') { return } + if ($variable.Name -match $this.Pattern) { + $variable + } + elseif ($variable.value.pstypenames -match $this.Pattern) { + $variable + } +} \ No newline at end of file