The Kloudless REST API supports accessing service providers through a variety of protocols, one of which is remote PowerShell. This is invaluable when managing Office 365 tenants. We introduced support for PowerShell connectivity to allow running Office 365 and Exchange Online PowerShell cmdlets via our REST API. Read more about that on our previous blog post here.
Our initial support for remote PowerShell requests relied on Basic Authentication using the admin’s Office 365 email address and password. However, several Office 365 admins follow best practices that encourage the use of Multi-Factor Authentication with Exchange Online PowerShell. Our engineers recently took up the challenge of introducing support for authorizing PowerShell cmdlets with Bearer tokens instead! This lets us avoid storing passwords, as well as follows the modern authentication flow supported by Office 365.
The latest release of Kloudless Enterprise includes support for this capability along with several enhancements to improve performance of PowerShell queries, such as multi-threaded PowerShell processes and background job management.
Authorizing PowerShell commands with OAuth
For an inside look into how the authorization process works, check out our PSMSOAuth PowerShell module here. Your users can install and run it as shown below:
This prompts the user for authorization credentials twice and then displays the authorization codes required to exchange with Office 365 for an access token to access the account.
The account can now receive PowerShell commands to execute via the Kloudless pass-through API. You can read more about connecting to accounts with MFA enabled on Microsoft’s docs here. Check out example API requests you can execute on our previous blog post here.
One of the challenges connecting to Office 365 PowerShell is the limit on the number of concurrent sessions allowed. Microsoft caps the number of sessions at three. This makes it necessary to strictly manage timeouts as well as open sessions to avoid running out of connections when making several API requests, especially concurrent ones.
In addition, a PowerShell process can only execute a single command at a time, unless the command is set up to execute in the background.
Kloudless utilizes a job queue that feeds PowerShell commands to background workers managing individual PowerShell processes, each of which manage multiple commands simultaneously. This greatly improves the performance and scalability of remote PowerShell requests while maintaining per-account isolation guarantees.
The Kloudless PowerShell interface has been architected to support connecting to a variety of services provided by Microsoft through a common API request format powered by our pass-through APIs. Your application can manage any Office 365 or Azure customer’s tenant through a REST API rather than dropping to the shell. Let us handle that for you!
Have any questions or feedback? We’d love to hear from you at firstname.lastname@example.org!