I've been trying to define variables for a PowerShell JEA session in configuration files using VariableDefintions
.
However, access to the defined variables is denied. All other configurations with VisibleCmdlets
, FunctionDefinitions
, etc. are working.
VariableDefinitions @(
@{ Name = 'Test'; Value = 'blah' }
}
After successfully entering the configured session interactively, I'm denied access to the defined variable from the console.
[remotehost]: PS> $Test
Cannot access the variable '$Test' because it is a private variable.
+ ----
+ CategoryInfo : PermissionDenied (Test.String) [], SessionException
+ FullyQualifiedErrorId : VariableIsPrivate
But since I've enabled FullLanguage mode, I am able to define variables to be used in an interactive session anyhow. So I'm using that as a work around.
As @Mathias is stating...
Variables defined using VariableDefintions
in JEA are only available to specified functions and scripts.
Trying to access them from an interactive JEA console session is not possible.
Very good to use if I need to hide sensitive data.
Very sensitive data should of course be handled using SecureString
when possible or a SecretVault
system.