$Host.Name / (Get-Host).Name and Using it with Invoke-Command

Ask your PowerShell-related questions, including questions on cmdlet development!
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.

This forum is a space to discuss coding in PowerShell, and technical issues related to development.

- Question about a licensed SAPIEN product? Post here: Product Support for Registered Users
- Question about a trial SAPIEN product? Post here: Former and Future Customers - Questions
This topic is 1 month and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
ITVendor
Posts: 2
Last visit: Tue Dec 03, 2024 9:41 am

$Host.Name / (Get-Host).Name and Using it with Invoke-Command

Post by ITVendor »

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)?
User avatar
Alexander Riedel
Posts: 8601
Last visit: Wed Dec 11, 2024 10:07 am
Answers: 23
Been upvoted: 43 times

Re: $Host.Name / (Get-Host).Name and Using it with Invoke-Command

Post by Alexander Riedel »

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.
ITVendor
Posts: 2
Last visit: Tue Dec 03, 2024 9:41 am

Re: $Host.Name / (Get-Host).Name and Using it with Invoke-Command

Post by ITVendor »

I appreciate the idea -- I'm going to work though this, thank you.
This topic is 1 month and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked