Connect-MicrosoftTeams

The Connect-MicrosoftTeams cmdlet connects an authenticated account to use for Microsoft Teams cmdlet requests. You can use this authenticated account only with Microsoft Teams cmdlets.

Syntax

Connect-MicrosoftTeams
       [-TenantId <String>]
       [-Credential <PSCredential>]
       [-AccountId <String>]
       [-LogLevel <LogLevel>]
       [-LogFilePath <String>]
       [-TeamsEnvironmentName <String>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Connect-MicrosoftTeams
       -TenantId <String>
       -CertificateThumbprint <String>
       -ApplicationId <String>
       [-LogLevel <LogLevel>]
       [-LogFilePath <String>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Connect-MicrosoftTeams
       [-TenantId <String>]
       -AadAccessToken <String>
       [-MsAccessToken <String>]
       [-ConfigAccessToken <String>]
       -AccountId <String>
       [-LogLevel <LogLevel>]
       [-LogFilePath <String>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Connect-MicrosoftTeams
       [-TenantId <String>]
       [-AccountId <String>]
       [-Identity]
       [-ManagedServicePort <Int32>]
       [-ManagedServiceHostName <String>]
       [-ManagedServiceSecret <SecureString>]
       [-LogLevel <LogLevel>]
       [-LogFilePath <String>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Examples

Example 1

PS C:\> Connect-MicrosoftTeams

Prompts for user credentials to connect and manage a Microsoft Teams environment.

Example 2

PS C:\> Connect-MicrosoftTeams -TeamsEnvironmentName TeamsGCCH

Specifies that the organization being managed is in the Teams GCC High environment, so connect to that environment.

Example 3

PS C:\> Connect-MicrosoftTeams -TenantId c3eac90d-eb4b-48ef-ac86-7acac472d3cd -CertificateThumbprint 9b6ac64bfb8b48dbb53cca75fb33ce2d -applicationid daaaf729-aaff-45ba-8055-a39dd618fe24

Connects to Microsoft Teams PowerShell using a Certificate and an applicationId.

Example 4

PS C:\> Connect-MicrosoftTeams -AadAccessToken c3eac90deb4b48efac867acac472d3cd -AccountId user@domain.com

Connects to Microsoft Teams PowerShell using an Azure Active Directory Graph access token.

Parameters

-AadAccessToken

Specifies a Azure Active Directory Graph access token.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-AccountId

Specifies the ID of an account. You must specify the UPN of the user when authenticating with a user access token.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ApplicationId

Specifies the application ID of the service principal.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-CertificateThumbprint

Specifies the certificate thumbprint of a digital public key X.509 certificate of a user account that has permission to perform this action.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ConfigAccessToken

{{ Fill ConfigAccessToken Description }}

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies a PSCredential object. For more information about the PSCredential object, type Get-Help Get-Credential.

The PSCredential object provides the user ID and password for organizational ID credentials.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Identity

Login using managed service identity in the current environment.

Type:SwitchParameter
Aliases:MSI, ManagedService
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-LogFilePath

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.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-LogLevel

Specifies the log level. The acceptable values for this parameter are:

  • Info
  • Error
  • Warning
  • None

The default value is Info.

Type:LogLevel
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ManagedServiceHostName

Host name for managed service login.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ManagedServicePort

Port number for managed service login.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ManagedServiceSecret

Secret, used for some kinds of managed service login.

Type:SecureString
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-MsAccessToken

Specifies a Microsoft Graph access token.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TeamsEnvironmentName

Use this setting if your organization is in one of the Teams Government Cloud environments.

Specify "TeamsGCCH" if your organization is in the GCC High Environment. Specify "TeamsDOD" if your organization is in the DoD Environment.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TenantId

Specifies the ID of a tenant.

If you do not specify this parameter, the account is authenticated with the home tenant.

You must specify the TenantId parameter to authenticate as a service principal or when using Microsoft account.

Type:String
Aliases:Domain, TenantDomain
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Notes

Tips for troubleshooting:

1. Confirm SAML 2.0 is being used.
IDP is outputting invalid SAML information. Needs to have SAML 2.0 vs. SAML 1.0 for the module to connect. You might experience an error if the Identity Provider (IDP) only allows the use of SAML 1.0 when trying to auth via basic authentication. Which in turn, isn't expected to work because the cmdlet expects either OAUTH2 (which is used when doing just connect-microsofteams), or SAML 2.0.

2. Confirm you have the latest version of the cmdlet.
You can find the version by running: `get-module -listavailable` and then looking for the MicrosoftTeams name and the version to the left of it. For more information and how to download the module, see Teams PowerShell Overview