andycattle / automate-azuremfa-hardware-totp

PowerShell script that can help automate the process of importing and activating hardware TOPT tokens into Azure MFA. Currently there are no built-in PowerShell commands for this purpose.
MIT License
4 stars 1 forks source link

Arithmetic operation resulted in an overflow #1

Open RalphK83 opened 1 year ago

RalphK83 commented 1 year ago

Hi, we are trying to import and activate our feitian c200 tokens. But we are getting the following script (Import is working but not the activation):

Token Upload Completed Exception calling "ToInt64" with "1" argument(s): "Arithmetic operation resulted in an overflow." At C:\admin\Add-AzureMFAToken.ps1:71 char:5 $unixTime = [Convert]::ToInt64([Math]::Floor($span / $WINDOW)) CategoryInfo : NotSpecified: (:) [], MethodInvocationException FullyQualifiedErrorId : OverflowException Attempting to activate token

kawhiteMBU commented 1 year ago

Hopefully this will ping author. Same error for me with Deepnet Security SafeID tokens If I go back and run the line from the script it completes fine: $unixTime = [Convert]::ToInt64([Math]::Floor($span / $WINDOW)) $unixTime 27964406

Emalf13 commented 1 year ago

I found these failures to be false errors. Instead, they were caused by a delay in Azure after the upload completed. Is it me or is Microsoft getting slower?

Anyway, I managed to get this working with a simple modification of the code. I simply added a Sleep (Start-Sleep) just before the Token Activation, after the '$payload' Parameters. I've up'ed mine to 40 seconds and now our OATH tokens (c200, c202, OTPCN & miniOTP2) all Activate successfully 99% of the time. Occassionally it throws a wobbly, but nothing like before.