Elevation and credential object from one 'credentials' request

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
mark106
Posts: 22
Joined: Mon Jan 09, 2017 8:15 am

Elevation and credential object from one 'credentials' request

Post by mark106 »

Hi.

Is there a way to elevate a PowerShell Studio built .EXE and get those same credentials (used to elevate) into a PScredential object for use within the script?

I currently have a project that needs to run elevated, but it also requires the credentials for some futher operations. I am currently embedding the manifest for elevation (which, in practice, is prompting the (standard) users for "admin" creds) and then I have to prompt for the ("admin") password again in order to have those credentials available within the script.

The only other way I can think to do this is to create a small ("launcher") exe that takes in the creds, launches the actual exe elevated - using something like ........
  1. Start-Process powershell.exe -Credential $cred -WindowStyle Hidden -Args '-noprofile', '-command', "Start-Process 'D:\psGUI.exe' -Verb RunAs"
.... and then passes the credentials to it - which, as I understand it, can only be done as a string - is that right?

Is there a better, more elegant, way to this?

Thanks

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.182
OS: Windows 7 Professional (64 Bit)
Build: v6.1.7601.65536

jvierra
Posts: 14672
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Elevation and credential object from one 'credentials' request

Post by jvierra »

You cannot do what you ask. You cannot pass an object as a string.

User avatar
mark106
Posts: 22
Joined: Mon Jan 09, 2017 8:15 am

Re: Elevation and credential object from one 'credentials' request

Post by mark106 »

Indeed. So that approach would need the password to be passed as a string (encrypted) so that a PScredential object could be created in the "main" .exe.

However, is this approach (to get credentials and elevation) the right way - or is there a better method?

Thanks

jvierra
Posts: 14672
Joined: Tue May 22, 2007 9:57 am
Answers: 6
Has voted: 1 time
Been upvoted: 5 times
Contact:

Re: Elevation and credential object from one 'credentials' request

Post by jvierra »

That seems about right.