We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Connect to Microsoft Teams

December 08, 2021 Views: 4526

The script establishes a connection to Microsoft Teams. The script requires the MicrosoftTeamsPowerShell module to be installed on the computer where Adaxes service runs.

Edit Remove
PowerShell
# Get access tokens
$graphToken = $Context.CloudServices.GetAzureAuthAccessToken("https://graph.microsoft.com")
$teamsToken = $Context.CloudServices.GetAzureAuthAccessToken("48ac35b8-9aa8-4d74-927d-1f4a14a0b239")

# Connect to Microsoft Teams
try
{
    Connect-MicrosoftTeams -AccessTokens @($graphToken, $teamsToken)
    
    $team = Get-Team -DisplayName "My Team" # TODO: replace with the code you need to execute
}
finally
{
    # Close the connection and release resources
    Disconnect-MicrosoftTeams -Confirm:$False
}
Comments 5
avatar
TJ Umredkar Apr 26, 2021
Hi, would you please provide more instructions on how to do the following steps:

-Assign the certificate to the Azure application whose credentials were used to register your Microsoft 365 tenant in Adaxes.
-Grant Azure application access to Microsoft Teams.
-Install the certificate on the computer where Adaxes service runs.
avatar
Support Apr 28, 2021
Please, note that the steps are required to make it possible to connect to Microsoft Teams using the Connect-MicrosoftTeams cmdlet. These are Microsoft requirements and they are not related to Adaxes directly. Should you have any issues accomplishing the steps, we suggest considering possibility to contact Microsoft Support for further troubleshooting. However, below you can find an approximate list of steps you should take to accomplish the required configuration.

>-Assign the certificate to the Azure application whose credentials were used to register your Microsoft 365 tenant in Adaxes.
  1. Sign in to Azure AD portal.
  2. Navigate to and open the App registration service.
  3. Click the application whose credentials were used to register the Microsoft 365 tenant in Adaxes.
  4. Click Certificates & secrets.
  5. In the Certificates section, click Upload certificate.
  6. Select the certificate you generated to connect to Microsoft Teams.
  7. Click Add.


>-Grant Azure application access to Microsoft Teams.
  1. Sign in to Azure AD portal.
  2. Navigate to and open the App registration service.
  3. Click the application whose credentials were used to register the Microsoft 365 tenant in Adaxes.
  4. Click API permissions.
  5. Click Add a permission.
  6. Click Microsoft Graph.
  7. Click Application permissions.
  8. Select the permissions required to accomplish tasks in your script.
  9. Click Add permissions.
  10. Click Grant admin consent for <tenant name>. Admin consent is required to make the added permissions effective.


>-Install the certificate on the computer where Adaxes service runs.
On the computer where Adaxes service is installed, right-click the certificate file and then click Install Certificate. Follow the instructions in the Certificate Import Wizard.
avatar
itsupport Aug 26, 2021
Connect-MicrosoftTeams version 2.5.0 not working anymore :-(
Version 2.3.2 works but non cs* commands possible.

Managing teams with Adaxes withouth interactive login seems impossible for now
avatar
Support Aug 27, 2021
Hello,

> Connect-MicrosoftTeams version 2.5.0 not working anymore
Yes, that is correct and there is currently no related documentation from Microsoft.

>Version 2.3.2 works but non cs* commands possible.
Yes, the script works fine with the module version 2.3.2.

>Managing teams with Adaxes withouth interactive login seems impossible for now
That is not correct. You can specify user account credentials in the Run as section of the Run a program or PowerShell script action and then use them in your script. For details, see section Running the script as a specific user of the following SDK article: https://adaxes.com/sdk/ServerSideScripting/#running-the-script-as-a-specific-user.
avatar
itsupport Aug 30, 2021
works great!!! thank you so much!
Leave a comment
Loading...

Got questions?

Support Questions & Answers