ThomasKur / IntuneDocumentation

Automatic Intune Documentation to simplify the life of admins and consultants.
GNU General Public License v3.0
339 stars 87 forks source link

get-graphTokenForIntune : Failed to retrieve access token from Azure #10

Closed RaptorG closed 5 years ago

RaptorG commented 5 years ago

Receiving following error on global admin without MFA

get-graphTokenForIntune : Failed to retrieve access token from Azure At line:954 char:21

get-graphTokenForIntune : access token is null! At line:954 char:21

ThomasKur commented 5 years ago

Hi RaptorG, does the following work https://github.com/ThomasKur/IntuneDocumentation/issues/7 ?

RaptorG commented 5 years ago

Thanks that worked but then it failed again. I figured the script also requires AzureRM Module. I ran "Install-Module AzureRM -AllowClobber" and it worked for the most part but then failed at:

Invoke-RestMethod : {"ClassName":"Microsoft.Portal.Framework.Exceptions.ClientException", "Message":"Graph call failed with httpCode=NotFound, errorCode=Request_ResourceNotFound, errorMessage=Resource'232e9e8e-f508-4b3b-8cc7-bf09b70523c3' does not exist or one of its queried reference-property objects are not present., reason=Not Found, correlationId = 17fb2996-7b64-4924-9b68-543c45145ce9, response = {\"odata.error\":{\"code\":\"Request_ResourceNotFound\", \"message\":{\"lang\":\"en\",\"value\":\"Resource '232e9e8e-f508-4b3b-8cc7-bf09b70523c3' does not exist or one of its queried reference-property objects are not present.\"}, \"requestId\":\"bbac0b0c-25e9-4f98-9e59-5f637cb28be4\",\"date\":\"2018-11-06T10:08:14\"}}","Data":{}, "HResult":-2146233088,"XMsServerRequestId":null,"Source":null,"HttpStatusCode":404,"ClientData":{"errorCode":"Request_ResourceNotFound", "localizedErrorDetails":{"errorDetail":"Resource '232e9e8e-f508-4b3b-8cc7-bf09b70523c3' does not exist or one ofits queried reference-property objects are not present."}, "operationResults":null,"timeStampUtc":"2018-11-06T10:08:14.890125Z", "clientRequestId":"17fb2996-7b64-4924-9b68-543c45145ce9","internalTransactionId":"a53450cc-d24d-4af7-8291-34ec397527d4", "upn":"","tenantId":" Tenannt ID ","userObjectId":null}}

At C:\Tools\IntuneDocumentation-master\DocumentIntune.ps1:524 char:19

ThomasKur commented 5 years ago

Ok, if you have to add AllowClobber then this means, that some of the commands are already available in another module with the same name. Therefore all important commands from the azuread module will have a prefix like Get-AZUREADADUser, which further explains the commands which are not working... because they are perhaps used from another module on you system. So please try it on another system...

JanssenRemco commented 5 years ago

Had the same issue here. After installing the AzureRM module without AllowClobber ("Install-Module AzureRM") the script ran perfect on my machine.

ThomasKur commented 5 years ago

CHeck out the new version which is using the Graph PowerShell Module. This one should work without an issue Invoke-IntuneDocumentation.ps1