MSEndpointMgr/Intune

Tenant 'token' not found

Rokory opened this issue · 3 comments

When using any command, I get

Failure to acquire access token. Response with access token was null

When using the -Promptbehavior Auto or RefreshSession switch, a window opens with the following error message:

AADSTS90002: Tenant 'token' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct tenant ID. Check with your subscription administrator.

I have an active subscription.

Could you please show how the command you're trying to use looks like?

The command was, e. g.

Get-IntuneWin32App -TenantName eo2003.onmicrosoft.com

Trying to reproduce the problem today, everything worked okay. It seems, that closing the PowerShell session and opening it again, fixed the issue. Background information: The computer, I run the commands from, is joined directly zu an Azure AD Domain.

However, I found a minor glitch, which might be connected with the original problem:

  1. Run the command with one tenant, let's call it tenant1.onmicrosoft.com.
  2. I am prompted for credentials and login successfully.
  3. The command runs successfully.
  4. Then, I run the command with a different tenant, let's call it tenant2.onmicrosoft.com.
  5. I am not prompted for credentials, the command runs successfully, but returns the apps from tenant1.onmicrosoft.com.

When I append the -PromptBehavior Always parameter, I am prompted for credentials and the command runs against the correct tenant. This is quite confusing.

May I suggest to make the TenantName parameter optional in all commands, but instead introduce a Connect-IntuneWin32Apps or similar command, that must be run before any other command in your library, like most other cloud-related modules from Microsoft do?

I can't really see that it's a bit confusing, because when switching tenants it's should be obvious that need to retrieve new credentials for the cmdlet to execute properly. I'll however consider to improve the experience and add a Connect cmdlet to align with other cloud based modules.