Skip to main content

Connect-Tenant

Connect to your Microsoft 365 tenant with PowerShell to copy teams

Updated over 2 months ago

Command

Connect-Tenant

Description

The command to connect to a Microsoft 365 tenant to do a copy.

Note: Currently, Connect-Tenant only works with Microsoft Teams PowerShell migrations.

Examples

Connect to the Microsoft 365 tenant using Modern Authentication

$mytenant = Connect-Tenant -Domain mytenantdomain -ModernAuth

Connect to the Microsoft 365 tenant using Modern Authentication with UserName

$mytenant = Connect-Tenant -Domain mytenantdomain -ModernAuth -UserName [email protected]

Note: You will get prompted to enter your password in the PowerShell window.

Connect to the Microsoft 365 tenant using Modern Authentication with UserName and password

$mypassword = ConvertTo-SecureString "mypassword" -AsPlainText -Force
$mytenant = Connect-Tenant -Domain mytenantdomain -ModernAuth -UserName [email protected] -Password $mypassword

Connect to the Microsoft 365 tenant with the user's current Windows credentials

Connect-Tenant -Domain mytenantdomain

Note: 'mytenantdomain' is the part before '.sharepoint.com' in the SharePoint URL. For example, 'https://mytenantdomain.sharepoint.com/sites/sitecollection'.

Connect to the Microsoft 365 tenant with a username

Connect-Tenant -Domain mytenantdomain -Username myusername

Connect to the Microsoft 365 tenant with username and password

$mypassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Force

$mytenant = Connect-Tenant -Domain mytenantdomain -Username myusername -Password $mypassword

Connect to the Microsoft 365 tenant without single sign-on (SSO)

Connect-Tenant -Domain mytenantdomain -Browser -DisableSSO

Connect to the Microsoft 365 tenant with proxy settings

$proxySettings = New-ProxySettings -Server myproxyserver -Port 888

Connect-Tenant -Domain mytenantdomain -ProxySettings $proxySettings

Connect to the Microsoft 365 tenant using Browser Authentication

Connect-Tenant -Domain mytenantdomain -Browser

Connect to the Microsoft 365 tenant using Browser Authentication with proxy settings

$proxySettings = New-ProxySettings -Server myproxyserver -Port 888

Connect-Tenant -Domain mytenantdomain -Browser -ProxySettings $proxySettings

Connect to the Microsoft 365 tenant using existing tenant connection credentials

$connection = Connect-Tenant -Domain "mytenantdomain" -Browser

Connect-Tenant -Domain "mytenantdomain" -UseCredentialsFrom $connection

Connect to the Microsoft 365 tenant using an existing site connection credentials

$connection = Connect-Site -Url "http://mytenantdomain/sites/mysitecollection" -Browser

Connect-Tenant -Domain "mytenantdomain" -UseCredentialsFrom $connection

Syntax

Connect-Tenant
-Domain <String>
[-ProxySettings <ProxySettings>]
[-AddToExplorer <SwitchParameter>]
-UserName <String>
-Password <SecureString>
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-Credential <PSCredential>
[-ProxySettings <ProxySettings>]
[-AddToExplorer <SwitchParameter>]
-UserName <String>
-Password <SecureString>
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-UseCredentialsFrom <ConnectionEntity>
[-AddToExplorer <SwitchParameter>]
-UserName <String>
-Password <SecureString>
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-Browser <SwitchParameter>
[-DisableSSO <SwitchParameter>]
[-ProxySettings <ProxySettings>]
[-AddToExplorer <SwitchParameter>]
-UserName <String>
-Password <SecureString>
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-UserName <String>
-Password <SecureString>
[-ProxySettings <ProxySettings>]
[-AddToExplorer <SwitchParameter>]
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-UserName <String>
-Password <SecureString>
-ModernAuth <SwitchParameter>
Connect-Tenant
-Domain <String>
-ModernAuth <SwitchParameter>
-UserName <String>
-Password <SecureString>

Parameters

-AddToExplorer <SwitchParameter>

Adds the connection to the ShareGate explorer.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Browser <SwitchParameter>

Use browser authentication.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Browser

Aliases

None

-Credential <PSCredential>

Specifies the credentials.

Required?

True

Default value

None

Accept pipeline input?

True (ByValue, ByPropertyName)

Accept wildcard characters?

False

Parameter set name

Credential

Aliases

None

-DisableSSO <SwitchParameter>

Turns off the auto-login feature to connect to a Microsoft 365 site with another user account.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Browser

Aliases

None

-Domain <String>

Sets the domain name of the Microsoft 365 tenant. The domain name in this example is 'contoso': 'https://contoso.sharepoint.com/sites/sitecollection'.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-ModernAuth <SwitchParameter>

Use modern authentication.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

ModernManualAuth, ModernAuth

Aliases

None

-Password <SecureString>

Specifies the password. Use single quotation marks (') to pass the string to the command exactly as you type it.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Manual

Aliases

None

-ProxySettings <ProxySettings>

Sets proxy settings for connecting to the SharePoint site.

Required?

False

Default value

None

Accept pipeline input?

True (ByValue, ByPropertyName)

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-UseCredentialsFrom <ConnectionEntity>

Use credentials from another connection.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

UseCredentialsFrom

Aliases

None

-UserName <String>

Specifies the username.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Manual

Aliases

None

Did this answer your question?