[GH-ISSUE #144] Could not load tenants: Failed to connect to API: #88

Closed
opened 2026-03-02 12:03:45 +03:00 by kerem · 3 comments
Owner

Originally created by @karnophage on GitHub (Oct 28, 2021).
Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/144

Describe the bug
Permissions test says: We could not connect to the API to retrieve the permissions. There might be a problem with the secure application model configuration. The returned error is: 400 - Response status code does not indicate success: 400 (Bad Request).

I understand this is to do with the Secure App Model config, but I don't know where to start troubleshooting that.

Running the checkup script you posted, produces the following:

C:\kris\cyberdrain\checkup.ps1 : Could not connect to Graph API for *******.onmicrosoft.com. Cannot validate argument on parameter 'Tenant'. The argument is
null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:1 char:1

  • .\checkup.ps1
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1
    
    

New-PSSession : [ps.outlook.com] Connecting to remote server ps.outlook.com failed with the following error message : For more information, see the
about_Remote_Troubleshooting Help topic.
At C:\kris\cyberdrain\checkup.ps1:33 char:20

  • ... $session = New-PSSession -ConfigurationName Microsoft.Exchange -Conn ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    • FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed
      C:\kris\cyberdrain\checkup.ps1 : Could not connect to Exchange for ******.onmicrosoft.com. Cannot validate argument on parameter 'Session'. The argument is
      null. Provide a valid value for the argument, and then try running the command again.
      At line:1 char:1
  • .\checkup.ps1
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1
    
    

C:\kris\cyberdrain\checkup.ps1 : Could not connect to Graph API for *****.onmicrosoft.com. Cannot validate argument on parameter 'Tenant'. The argument is
null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:1 char:1

  • .\checkup.ps1
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1
    
    

This would point to a permission error in the SAM, but I've no idea where to start looking. I've run it and it returns keys fine. I've put those into the scripts.

Originally created by @karnophage on GitHub (Oct 28, 2021). Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/144 **Describe the bug** Permissions test says: We could not connect to the API to retrieve the permissions. There might be a problem with the secure application model configuration. The returned error is: 400 - Response status code does not indicate success: 400 (Bad Request). I understand this is to do with the Secure App Model config, but I don't know where to start troubleshooting that. Running the checkup script you posted, produces the following: C:\kris\cyberdrain\checkup.ps1 : Could not connect to Graph API for *******.onmicrosoft.com. Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:1 char:1 + .\checkup.ps1 + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1 New-PSSession : [ps.outlook.com] Connecting to remote server ps.outlook.com failed with the following error message : For more information, see the about_Remote_Troubleshooting Help topic. At C:\kris\cyberdrain\checkup.ps1:33 char:20 + ... $session = New-PSSession -ConfigurationName Microsoft.Exchange -Conn ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed C:\kris\cyberdrain\checkup.ps1 : Could not connect to Exchange for ******.onmicrosoft.com. Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again. At line:1 char:1 + .\checkup.ps1 + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1 C:\kris\cyberdrain\checkup.ps1 : Could not connect to Graph API for *****.onmicrosoft.com. Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:1 char:1 + .\checkup.ps1 + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,checkup.ps1 This would point to a permission error in the SAM, but I've no idea where to start looking. I've run it and it returns keys fine. I've put those into the scripts.
kerem 2026-03-02 12:03:45 +03:00
  • closed this issue
  • added the
    NotABug
    label
Author
Owner

@gavsto commented on GitHub (Oct 28, 2021):

@karnophage Have a read of https://www.gavsto.com/secure-application-model-for-the-layman-and-step-by-step/

If that doesn't help please come in to the MSPGeek Slack #cipp and I can try help further.

As this is not related to the product but more the Secure Application Model I'm going to close it.

<!-- gh-comment-id:953895600 --> @gavsto commented on GitHub (Oct 28, 2021): @karnophage Have a read of https://www.gavsto.com/secure-application-model-for-the-layman-and-step-by-step/ If that doesn't help please come in to the MSPGeek Slack #cipp and I can try help further. As this is not related to the product but more the Secure Application Model I'm going to close it.
Author
Owner

@karnophage commented on GitHub (Nov 2, 2021):

Sorted using your direction, thanks @gavsto

<!-- gh-comment-id:957069845 --> @karnophage commented on GitHub (Nov 2, 2021): Sorted using your direction, thanks @gavsto
Author
Owner

@joshk1902 commented on GitHub (Dec 13, 2023):

@karnophage What was the fix?

<!-- gh-comment-id:1853185819 --> @joshk1902 commented on GitHub (Dec 13, 2023): @karnophage What was the fix?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/CIPP#88
No description provided.