I have a PowerShell/JEA Session Configuration/endpoint. I want my form/application to be the only entity allowed to use it. This is to say, that I don't want people using it from the ConsoleHost, Code, ISE, etc. via Invoke-Command or Enter-PSSession. I thought I had an idea, but even though (Get-Host).Name returns PrimalScriptHostImplementation inside the form/application when Invoke-Command is run by the form/application, (Get-Host).Name is still ServerRemoteHost -- this is the same as if were Invoke-Command or Enter-PSSession.
How can I only allow my form/application to use my session configuration/endpoint? What can I pass into my StartupScript/ScriptToProcess that's unique to the application/form that can't be spoofed -- that's unique to the form/environment and built-in (preferably not text in the application/form that I add)?
$Host.Name / (Get-Host).Name and Using it with Invoke-Command
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8575
- Last visit: Fri Nov 01, 2024 12:24 pm
- Been upvoted: 42 times
Re: $Host.Name / (Get-Host).Name and Using it with Invoke-Command
Calculate a hash e.g. over the date, time and target machine name and pass it on the command line. The called script does the same calculation, then the hash should match. Makes sure that even if someone gets a hold of one hash, it won't work thereafter.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: $Host.Name / (Get-Host).Name and Using it with Invoke-Command
I appreciate the idea -- I'm going to work though this, thank you.