Commands › Microsoft Teams

Connect-MicrosoftTeams

Microsoft Teams MicrosoftTeams Connect-*

The Connect-MicrosoftTeams cmdlet connects an authenticated account for use with cmdlets from the MicrosoftTeams module.

Quick start script

# Connect-MicrosoftTeams — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-MicrosoftTeams -CertificateThumbprint $thumb -ApplicationId $appId -TenantId $tenantId

# 2. Run and inspect
Connect-MicrosoftTeams -ApplicationId <String> -Certificate <X509Certificate2> -CertificateThumbprint <String> | Format-List

# 3. Export for evidence / drift tracking
Connect-MicrosoftTeams | Export-Clixml .\MicrosoftTeams-$(Get-Date -Format yyyyMMdd).xml

Syntax — 4 parameter sets

UserCredential (Default)

Connect-MicrosoftTeams
[-TenantId <String>]
[-Credential <PSCredential>]
[-AccountId <String>]
[-LogLevel <LogLevel>]
[-LogFilePath <String>]
[-TeamsEnvironmentName <String>]
[-UseDeviceAuthentication]
[-DisableWAM]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

ServicePrincipalCertificate

Connect-MicrosoftTeams
-TenantId <String>
-Certificate <X509Certificate2>
-ApplicationId <String>
[-LogLevel <LogLevel>]
[-LogFilePath <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

ServicePrincipalCertificateThumbprint

Connect-MicrosoftTeams
-TenantId <String>
-CertificateThumbprint <String>
-ApplicationId <String>
[-LogLevel <LogLevel>]
[-LogFilePath <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

AccessTokens

Connect-MicrosoftTeams
[-TenantId <String>]
-AccessTokens <String[]>
[-LogLevel <LogLevel>]
[-LogFilePath <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

Parameters (17)

ParameterTypeRequiredWhat it controls
-AccountId String Specifies the ID of an account.
-ApplicationId String yes Specifies the application ID of the service principal that is used in application-based authentication.
-Certificate X509Certificate2 yes Specifies the certificate that is used for application-based authentication. A valid value is the X509Certificate2 object value of the certificate.
-CertificateThumbprint String yes Specifies the certificate thumbprint of a digital public key X.509 certificate of an application that has permission to perform this action.
-Confirm SwitchParameter Prompts you for confirmation before running the cmdlet.
-Credential PSCredential Specifies a PSCredential object. For more information about the PSCredential object, type Get-Help Get-Credential.
-DisableWAM SwitchParameter Disables Web Account Manager (WAM) authentication for the connection. Use this switch only if you encounter WAM-related connection errors.
-Identity SwitchParameter yes Login using managed service identity in the current environment. For *-Cs cmdlets, this is supported from version 5.8.1-preview onwards.
-LogFilePath String The path where the log file for this PowerShell session is written to. Provide a value here if you need to deviate from the default PowerShell log file location.
-LogLevel LogLevel Specifies the log level. The acceptable values for this parameter are:
-ManagedServiceHostName String Host name for managed service login.
-ManagedServicePort Int32 Port number for managed service login.
-ManagedServiceSecret SecureString Secret, used for some kinds of managed service login.
-TeamsEnvironmentName String Specifies the Teams environment. The following environments are supported:
-TenantId String Specifies the ID of a tenant.
-UseDeviceAuthentication SwitchParameter Use device code authentication instead of a browser control.
-WhatIf SwitchParameter Shows what would happen if the cmdlet runs. The cmdlet is not run.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.