Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -TrustedInstaller switch to Invoke-Gsudo #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ImportTaste
Copy link

This allows -TrustedInstaller to be used to send --ti to gsudo.

I gave -TrustedInstaller and -Credential their own parameter sets so they can't be used together. Through this process, I found out that even if you declare them together while using a string for the credential, the credential login from Windows still pops up before stopping you.

I removed the use of $dbg in the Start-Process line and the $user declaration since neither variable was being used for anything.

Honestly, I'd like to do a more comprehensive re-write of this script at some point.

@gerardog
Copy link
Owner

This allows -TrustedInstaller to be used to send --ti to gsudo.

Awesome! Thank you for getting involved.

I gave -TrustedInstaller and -Credential their own parameter sets so they can't be used together.

I like that.

Through this process, I found out that even if you declare them together while using a string for the credential, the credential login from Windows still pops up before stopping you.

Sorry, I don't understand...

I removed the use of $dbg in the Start-Process line and the $user declaration since neither variable was being used for anything.

💪

Honestly, I'd like to do a more comprehensive re-write of this script at some point.

Me too! Actually, I've already started rewriting it some time ago... But I got to a halt. I found a breaking change in the new approach and since I am doing gsudo only in my spare time, I didn't had the time to complete the re-write. To make things 'worse' I accidentally pushed, (and hence released in v2.4.0) the new approach as a new script named Invoke-ElevatedCommand.

The script file name was not even meant to be published, I put some alternative name to keep both files at the same time :).
I did a huge mess.

The new script focuses on having all gsudo arguments, and using the hack of passing a scriptblock to gsudo pwsh which is then transparently serialized (user runs gsudo {echo 1} but the following is actually executed: gsudo -encodedCommand XX....XX, try it by running gsudo --debug {something} and looking at the Command Line info line.)

I didn't released it because Invoke-gsudo works better in try catch scenarios, or at least it mimics more closely what happens with invoke-command errors, so it would be a breaking change.

The idea was not to release Invoke-ElevatedCommand yet, and replace Invoke-Gsudo with it. The new approach has a powershell native syntax, while also using the brackets/encodedCommand trick (which performs way faster returning serialized objects). So I suggest you take a look at Invoke-ElevatedCommand first and then let me know what things do you think can be improved.

@ImportTaste
Copy link
Author

ImportTaste commented Sep 20, 2023

Sorry, I don't understand...

This'll pop up first:

image

But only after it closes does it validate the parameters.

To counteract this, I have it call Get-Credential (if -Credential is a string) within the if-statement instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants