Script Repository


Connect to Microsoft Teams

April 23, 2021
221

The script establishes connection to Microsoft Teams. For the script to work you need to install a certificate for connection to Microsoft Teams on the computer where Adaxes service runs. To do so:

  1. Create a certificate using the New-PnPAzureCertificate cmdlet.
  2. Assign the certificate to the Azure application whose credentials were used to register your Microsoft 365 tenant in Adaxes.
  3. Grant Azure application access to Microsoft Teams.
  4. Install the certificate on the computer where Adaxes service runs.

Also, the script requires the MicrosoftTeamsPowerShell module to be installed on the computer where Adaxes service runs.

Parameters:

Edit Remove
PowerShell
$certificateThumbprint = "9BCE7405DD63FD8DE7486FDD32D111667197BB8E" # TODO: modify me

# Connect to Microsoft Teams
$tenant = $Context.CloudServices.GetO365Tenant()
$credential = $tenant.GetCredential()

try
{
    Connect-MicrosoftTeams -TenantId $tenant.TenantId -CertificateThumbprint $certificateThumbprint -applicationid $credential.AppId
    
    $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 ( 2 )
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.
Leave a comment

Related Scripts