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

Prompting for Automate Server when using -twofactortoken #71

Open
ghost opened this issue Mar 1, 2022 · 2 comments
Open

Prompting for Automate Server when using -twofactortoken #71

ghost opened this issue Mar 1, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 1, 2022

Connect-AutomateAPI -ClientID $ID -Credential $Credential
-Server $server -SkipCheck
-TwoFactorToken $TwoFactorPasscode

Output:
Please enter your Automate Server address, IE: rancor.hostedrmm.com:
Expected:
Successfully tested and connected to the Automate REST API. Token will expire at 2022-03-0
1T18:24:49

Wondering if this is expected but when removing -TwoFactorToken it works correctly

@DarrenWhite99
Copy link
Collaborator

Moving line 89 to 108 should resolve the issue. Feel free to test it if you want to help speed it along.
The line is:
If ($TwoFactorToken -match '.+') {$Force=$True}
and it just needs to be moved to the line above:
} #End Begin

One issue though with your example is that you are skipping validation (-SkipCheck) and passing a -TwoFactorToken. That won't work. I'll need to try to sort out how to tag the parameter sets to prevent this from being accepted. The goal of this function is to get an authentication token. Skipcheck is for use when you want to pre-load the values in the script variables but not actually connect. (Like loading them from a stored file). Then you can just call connect-automateapi and it will try to validate things, AT WHICH POINT you would need the two factor token. So while it's not the cause of the issue you reported, if you are providing the -TwoFactorToken parameter you should not use -Skiptest because the two factor token will just be thrown away.

@ITGuyFromIA2
Copy link

I have run into this same issue. Can confirm that moving line 89 to 108 seems to resolve the issue

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

No branches or pull requests

2 participants