PowerShell for Exchange/O365

Overview

The PowerShell connector enables your Leena AI Agents to integrate with Microsoft 365 and Exchange Online environments, facilitating automated PowerShell script execution, mailbox management, and distribution list operations.

PowerShell is Microsoft's task automation and configuration management framework. The PowerShell connector allows Leena AI to automate Microsoft 365 operations, manage Exchange Online resources, and execute custom scripts seamlessly.

API Details

Leena AI integrates with Microsoft 365 via Microsoft Graph API and Exchange Online PowerShell.

Documentation link: https://learn.microsoft.com/en-us/graph/overview

Setup

The PowerShell connector uses OAuth 2.0 authentication with Azure Active Directory.

Prerequisites

Before setting up the PowerShell connector, ensure you have:

  • Azure Active Directory (Azure AD) admin access
  • Microsoft 365 admin permissions
  • Access to Exchange Online
  • PowerShell execution permissions
  • Azure AD application registration capabilities
  • Access to your Leena AI workspace with connector management permissions

Get credentials

Here is how to register an application in Azure AD:

  1. Sign in to the Azure Portal
  2. Navigate to Azure Active Directory:
    1. Click on Azure Active Directory in the sidebar
    2. Select App registrations
  3. Create New Registration:
    1. Click New registration
    2. Configure the application:
      • Name: Enter a descriptive name (e.g., "Leena AI PowerShell Connector")
      • Supported account types: Select based on your organization needs
      • Redirect URI: Can be configured later if needed
    3. Click Register
    4. Note down the Application (client) ID
  4. Create Client Secret:
    1. In your app registration, go to Certificates & secrets
    2. Click New client secret
    3. Add a description (e.g., "Leena AI PowerShell Secret")
    4. Select an expiration period
    5. Click Add
    6. Important: Copy the client secret value immediately - it won't be shown again
  5. Configure API Permissions:
    1. In your app registration, go to API permissions
    2. Click Add a permission
    3. Select Microsoft Graph
    4. Add the following Application permissions:
      • User.Read.All
      • Group.ReadWrite.All
      • Mail.ReadWrite
    5. Add Exchange Online permissions if needed
    6. Click Grant admin consent for your organization
  6. Note Your Tenant ID:
    1. In Azure AD overview, locate your Tenant ID
    2. Copy this value for configuration

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "PowerShell" and select it from the list to add its new connector
  4. Start configuring the connector
    1. Client ID: Your Azure AD application (client) ID
    2. Client Secret: The secret created in Azure AD
    3. Tenant ID: Your Azure AD tenant ID
    4. Scope: Microsoft Graph API scope (Pre-filled with 'https://graph.microsoft.com/.default')
  5. Save the connector configuration

Actions

The following actions are supported for the PowerShell connector:

Create Shared Mailbox

Creates a new shared mailbox in Microsoft 365 or Exchange Online. The Agent can leverage the skill (workflow), which has been designed to create a shared mailbox, once the user provides the required mailbox details.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
Script TypeAction identifier for creating shared mailboxcreate-shared-mailbox
Shared Mailbox NameDisplay name for the mailboxMarketing Team
Shared Mailbox AliasAlias for the mailboxmarketing-team
Shared Mailbox EmailEmail address for the mailbox[email protected]

Here is a sample JSON input:

{
  "Script Type": "create-shared-mailbox",
  "Shared Mailbox Name": "Marketing Team",
  "Shared Mailbox Alias": "marketing-team",
  "Shared Mailbox Email": "[email protected]"
}

Response

Upon successful creation, the action returns confirmation of the created shared mailbox.

Add Users to Shared Mailbox

Adds users to an existing shared mailbox with specified access permissions. The Agent can leverage the skill (workflow), which has been designed to grant mailbox access to users. This action supports different types of access including Full Access, Send As, and Send on Behalf permissions.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
Script TypeAction identifier for adding mailbox permissionsadd-mailbox-permission
Shared Mailbox EmailTarget mailbox email address[email protected]
UsersList of users to add access for["[email protected]", "[email protected]"]
Access RightsType of permission to grantFullAccess

Here is a sample JSON input:

{
  "Script Type": "add-mailbox-permission",
  "Shared Mailbox Email": "[email protected]",
  "Users": [
    "[email protected]",
    "[email protected]"
  ],
  "Access Rights": "FullAccess"
}

Response

Upon successful execution, the action returns confirmation that users have been added to the shared mailbox with specified permissions.

Remove Users from Shared Mailbox

Removes users from an existing shared mailbox. The Agent can leverage the skill (workflow), which has been designed to revoke mailbox access from users. This action supports removing different types of access including Full Access, Send As, and Send on Behalf permissions.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
Shared Mailbox EmailTarget mailbox email address[email protected]
UsersList of users to remove access from["[email protected]", "[email protected]"]

Here is a sample JSON input:

{
  "Shared Mailbox Email": "[email protected]",
  "Users": [
    "[email protected]",
    "[email protected]"
  ]
}

Response

Upon successful execution, the action returns confirmation that users have been removed from the shared mailbox.

Create Distribution Group/List

Creates a new distribution list or group in Microsoft 365. The Agent can leverage the skill (workflow), which has been designed to create distribution lists for email communication.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
Script TypeAction identifier for creating distribution listcreate-distribution-list
List NameName of the distribution listAll Employees
List EmailEmail address for the distribution list[email protected]

Optional

NameDescriptionExample
MembersInitial members to add to the list["[email protected]", "[email protected]"]

Here is a sample JSON input:

{
  "Script Type": "create-distribution-list",
  "List Name": "All Employees",
  "List Email": "[email protected]",
  "Members": [
    "[email protected]",
    "[email protected]"
  ]
}

Response

Upon successful creation, the action returns confirmation of the created distribution list.

Add Members to Distribution Group/List

Adds members to an existing distribution list or group. The Agent can leverage the skill (workflow), which has been designed to add members to distribution lists. This is particularly useful for onboarding workflows where new employees need to be added to relevant distribution lists.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
List EmailDistribution list email address[email protected]
UsersList of members to add["[email protected]"]

Here is a sample JSON input:

{
  "List Email": "[email protected]",
  "Users": [
    "[email protected]"
  ]
}

Response

Upon successful execution, the action returns confirmation that members have been added to the distribution list.

Remove Members from Distribution Group/List

Removes members from an existing distribution list or group. The Agent can leverage the skill (workflow), which has been designed to remove members from distribution lists. This is particularly useful for offboarding workflows where departing employees need to be removed from distribution lists.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescriptionExample
List EmailDistribution list email address[email protected]
UsersList of members to remove["[email protected]"]

Here is a sample JSON input:

{
  "List Email": "[email protected]",
  "Users": [
    "[email protected]"
  ]
}

Response

Upon successful execution, the action returns confirmation that members have been removed from the distribution list.