Windows Unprivileged - Loading JEA Dynamically
Note that absolutely none of this is authoritative or directly based on relevant documentation. It’s mostly what I found and figured out and guessed and (in some cases) made up. Some of it may be wrong or dangerous or lead to disaster or confusion. I am not taking responsibility here for anything. Read and act on it at your own peril!
Put this into your $PROFILE to load all applicable JEA configurations by just typing jea.
function jea
{
$Host.UI.RawUI.WindowTitle = "JEA:"
(Get-ChildItem 'C:\Program Files\WindowsPowerShell\Modules\JEA\*.pssc').BaseName | ForEach-Object {
Import-PSSession (New-PSSession -ConfigurationName $_) -AllowClobber
if ($?) {$Host.UI.RawUI.WindowTitle += " $_"}
}#foreach
}This will
- load all applicable JEA session configurations based on JEA configuration files in the C:\Program Files\WindowsPowerShell\Modules\JEA\ directory
- create a session for each JEA session configuration and import it
- change the window (or tab) title to JEA: and a list of all imported JEA sessions
You can then use all cmdlets directly but they will run in the appropriate JEA session. Only for images (.exe) you need to enter or invoke a pssession to run.
To get rid of the limitations this might cause (depending on JEA configurations Get-Help might not work etc.), remove the pssessions and you should be free again.
Remove-PSSession *If you feel fancy you can also name the function Enable-JEA or Enable-Elevated.
Next: TBD