Connect-SPOService

将 SharePoint Online 管理员连接到 SharePoint Online 连接 (SharePoint Online 管理中心) 。 必须先运行此 cmdlet,然后才能运行任何其他 SharePoint Online cmdlet。

语法

Connect-SPOService
       [-Url] <UrlCmdletPipeBind>
       [[-Credential] <CredentialCmdletPipeBind>]
       [[-ClientTag] <String>]
       [-AuthenticationUrl] <String>
       [[-ModernAuth] <Boolean>]
       [[-UseSystemBrowser] <Boolean>]
       [<CommonParameters>]
Connect-SPOService
       [-Url] <UrlCmdletPipeBind>
       [[-Credential] <CredentialCmdletPipeBind>]
       [[-ClientTag] <String>]
       [[-Region] <AADCrossTenantAuthenticationLocation>]
       [[-ModernAuth] <Boolean>]
       [[-UseSystemBrowser] <Boolean>]
       [<CommonParameters>]

说明

Connect-SPOService cmdlet 将 SharePoint Online 管理员或 SharePoint Embedded 管理员连接到 SharePoint Online 管理中心。

仅从任何单个Windows PowerShell会话维护单个 SharePoint Online 服务连接。 换句话说,这是组织管理员连接内的每个地理位置。 Connect-SPOService运行 cmdlet 两次会隐式断开上一个连接。 Windows PowerShell会话将设置为为指定的新 SharePoint Online 管理员提供服务。

委派的合作伙伴管理员必须在同一Windows PowerShell会话中交换不同组织的连接。

您必须是 SharePoint Online 管理员或 SharePoint Embedded 管理员才能运行 cmdlet。

有关适用于 SharePoint Online 的 Windows PowerShell 的权限和最新信息,请参阅在线文档简介 SharePoint Online 命令行管理程序的简介

示例

-----------------------示例 1-----------------------------

Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential admin@contoso.com

示例 1 显示了具有凭据 admin@contoso.com 的 SharePoint Online 管理员如何连接到具有 URL 的 SharePoint Online 管理中心 <https://contoso-admin.sharepoint.com.>

-----------------------示例 2-----------------------------

$username = "admin@contoso.sharepoint.com"
$password = "password"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-SPOService -Url https://contoso-admin.sharepoint.com -Credential $cred

示例 2 显示具有用户名和密码的 SharePoint Online 管理员如何连接到具有 URL 的 SharePoint Online 管理中心 <https://contoso-admin.sharepoint.com.>

--------------------'---EXAMPLE 3-----------------------------

Connect-SPOService -Url https://contoso-admin.sharepoint.com

提示凭据。 如果帐户使用多重身份验证,则这是必需的。

-----------------------示例 4-----------------------------

Connect-SPOService -Url https://contoso-admin.sharepoint.com -Region ITAR

连接到指定区域的 SharePoint Online 管理中心。

-----------------------示例 5-----------------------------

Connect-SPOService -Credential $creds -Url https://tenant-admin.sharepoint.com -ModernAuth $true -AuthenticationUrl https://login.microsoftonline.com/organizations

使用 ModernAuth 标志连接到 SPO 服务。

-----------------------示例 6-----------------------------

Connect-SPOService -Url https://contoso-admin.sharepoint.com -UseSystemBrowser $true

使用 Microsoft 身份验证库 (MSAL) 进行身份验证,并在身份验证成功后连接到 SharePoint Online 管理中心。

参数

-AuthenticationUrl

Microsoft Entra跨租户身份验证服务的位置。 如果使用非默认的跨租户身份验证服务,则可以选择使用。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False
适用于:SharePoint Online

-ClientTag

允许将客户端标记追加到现有客户端标记。 (可选)在 CSOM http 流量中使用,以标识使用的脚本或解决方案。

类型:String
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False
适用于:SharePoint Online

-Credential

指定用于连接的凭据。 如果未提供凭据,则将出现一个提示输入凭据的对话框。 凭据必须是可以访问 SharePoint Online 管理中心网站的 SharePoint Online 管理员的凭据。

类型:CredentialCmdletPipeBind
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False
适用于:SharePoint Online

-ModernAuth

确保 SharePoint Online 租户管理 cmdlet 可以使用新式 TLS 协议连接到服务。

若要使用它,还需要提供 AuthenticationUrl 参数。

类型:Boolean
Position:Named
默认值:False
必需:False
接受管道输入:False
接受通配符:False
适用于:SharePoint Online

-Region

有效值为:Default |ITAR |德国 |中国

默认值为“default”。

注意:ITAR 值仅适用于 GCC High 和 DoD 租赁。

类型:AADCrossTenantAuthenticationLocation
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False
适用于:SharePoint Online

-Url

指定 SharePoint Online 管理中心网站的 URL。

类型:UrlCmdletPipeBind
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False
适用于:SharePoint Online

-UseSystemBrowser

用于使用 Microsoft 身份验证库 (MSAL) 对用户进行身份验证。

类型:Boolean
Position:5
默认值:None
必需:False
接受管道输入:False
接受通配符:False
适用于:SharePoint Online