Skip to content

/flags/teams/connect-microsoftteams-teamsenvironmentname

Connect-MicrosoftTeams -TeamsEnvironmentName: TeamsGCCH, TeamsDOD, TeamsChina

The commands on this page have not been executed by our verification runner yet.updated
tool
Microsoft Teams PowerShell
command
Connect-MicrosoftTeams
flag
-TeamsEnvironmentName
default
not set: commercial and GCC environments

Connect-MicrosoftTeams -TeamsEnvironmentName TeamsGCCH connects Teams PowerShell to a sovereign cloud instead of the commercial service. Without it, sign-in and every Cs cmdlet go to the commercial endpoints, which do not host GCC High, DoD or 21Vianet tenants. The reference lists the values: "Commercial or GCC environments: Don't use this parameter, this is the default. GCC High environment: TeamsGCCH. DoD environment: TeamsDOD. Microsoft Teams operated by 21Vianet: TeamsChina."

powershell
Connect-MicrosoftTeams -TeamsEnvironmentName TeamsGCCH
Connect-MicrosoftTeams -TeamsEnvironmentName TeamsDOD -UseDeviceAuthentication
Connect-MicrosoftTeams -TeamsEnvironmentName TeamsChina

Values by environment

Environment-TeamsEnvironmentNameExchange equivalent
Commercial (worldwide)do not usedo not use
GCC (moderate)do not usedo not use
GCC HighTeamsGCCH-ExchangeEnvironmentName O365USGovGCCHigh
DoDTeamsDOD-ExchangeEnvironmentName O365USGovDoD
Microsoft Teams operated by 21VianetTeamsChina-ExchangeEnvironmentName O365China

The parameter in the module

In MicrosoftTeams 8.0.0 the parameter is a string, available in the interactive (UserCredential), certificate and access-token parameter sets, with no list of allowed values enforced by PowerShell.

The module's Set-TeamsEnvironmentConfig cmdlet takes a parameter of the same name. Because nothing validates the value locally, a typo such as TeamsGCCHigh is only discovered when the sign-in fails. Copy the value from the table.

Pitfalls

  • GCC is not GCC High. GCC (moderate) tenants live in the commercial infrastructure and connect without the parameter.
  • Combine with your sign-in method. The parameter works with interactive sign-in, -UseDeviceAuthentication (device code sign-in) and app-only certificates.
  • Other services need their own settings. Exchange Online uses -ExchangeEnvironmentName, Security & Compliance PowerShell uses explicit URIs (Connect-IPPSSession -ConnectionUri).
  • Check the session. After connecting, Get-CsTenant should return your tenant. Cmdlets that fail with Session is not established mean the connection did not succeed.

FAQ

Do GCC (moderate) tenants need -TeamsEnvironmentName?

No. The reference says: Commercial or GCC environments, don't use this parameter, this is the default. Only GCC High, DoD and Microsoft Teams operated by 21Vianet need a value.

What happens with a wrong value?

The parameter is a plain string in module 8.0.0, so PowerShell does not reject a typo when binding. The sign-in then goes to an environment that does not know your tenant and fails. Copy the value exactly: TeamsGCCH, TeamsDOD or TeamsChina.

Is it the same as -ExchangeEnvironmentName?

It plays the same role for Teams, but the values differ: Exchange uses O365USGovGCCHigh, O365USGovDoD and O365China; Teams uses TeamsGCCH, TeamsDOD and TeamsChina.

Sources