Open ghost opened 2 years ago
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.
I have run into this same issue. Can confirm that moving line 89 to 108 seems to resolve the issue
Connect-AutomateAPI -ClientID $ID
-Credential $Credential
-Server $server-SkipCheck
-TwoFactorToken $TwoFactorPasscodeOutput: 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