SDK command error - "The input is not a valid Base-64 string..."

Brass Contributor

Whenever I perform ANY SDK command (i.e. get-Mguser, invoke-MgGraphrequest), I receive the following error.

Example 1:

Get-MgUser : The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

At line:2 char:1

+ Get-MgUser -Filter "userPrincipalName eq '$UPN'"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [Get-MgUser_List1], FormatException

+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List1

 

Example2:

Invoke-MgGraphRequest : The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
At line:4 char:14
+ ... response = (Invoke-MgGraphRequest -Uri $uri -Headers $headers -Method ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-MgGraphRequest], FormatException
+ FullyQualifiedErrorId : NotSpecified,Microsoft.Graph.PowerShell.Authentication.Cmdlets.InvokeMgGraphRequest

 

I am able to perform connect-mggraph and obtain the -scopes needed.  

I have done the following (and searched for the past few days):

Executed VSCode/Poweshell ISE/pwsh.exe with Administrator privs

Removed microsoft.graph modules and reinstalled version 1.10

 

I do not recall when this error began, but it's probably within the past week. I'm using Graph Explorer without error of course. I've had 2 Windows 10 updates on 6/20/2022. KB5014699 and Servicing Stack 10.0.19401.1737.

I realize "It works on my machine. What did you do to yours" is the most common answer. :)

 

Any guidance, workaround, solutions to try would be most welcome.

5 Replies
Hey Ken
Did you ever get a resolution to this? Happening to me as well.
I have not. Working on it a bit today and will report back if I find anything.
I've started having the same problem today (although it's worked once or twice). I had a look at the issues logged against the GitHub project (https://github.com/microsoftgraph/msgraph-sdk-powershell/issues) and no one else seems to have reported something similar.

@richardarcher 

We ran into this today as well - it was actually due to an invalid session after making an authentication change. I had a spare PS window in the background which was holding an MGGraph session open. I ran a manual disconnect-mggraph and then connect-mggraph and got the authorization pop up.

My mistake was assuming the session updated when I updated Teams, Office, etc. 

I knew it was something to do with the auth update we did, but I'm not sure why the base64 error is the result here. Hopefully this helps you guys out!

Surprisingly to me, this error is resolved as of this morning. Some of the troubleshooting I did was to use another computer, use a local profile (not a ADDS profile). Eliminate any VPNs. Use ProcMon. Spent enough time I just gave up.

 

This morning, I removed all files and folders related to Microsoft.Graph. Performed "Install-Module Microsoft.Graph -Scope AllUsers" from an administrator VSCode session to upgrade to 1.11.1.

Get-MgUser did not return an error.