安装 Microsoft Teams PowerShell 模块

本文介绍如何使用 PowerShell 库 安装 Microsoft Teams PowerShell 模块。 所有 Windows 平台上都支持 Microsoft Teams PowerShell 模块。 不支持 Mac。

要求

Microsoft Teams PowerShell 模块要求在所有平台上使用 PowerShell 5.1 或更高版本。 安装适用于操作系统 的最新版本的 PowerShell

若要检查 PowerShell 版本,请从 PowerShell 会话中运行以下命令:

$PSVersionTable.PSVersion

建议使用 Install-Module cmdlet 安装 Microsoft Teams PowerShell 模块。

如果PowerShell 库 (PSGallery) 未配置为 PowerShellGet 的受信任存储库,则首次使用 PSGallery 时,会看到以下消息:

Untrusted repository

You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the `Set-PSRepository` cmdlet.

Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

回答 “是”“是”, 以继续安装。

使用 PowerShellGallery 进行安装

Microsoft Teams PowerShell 模块当前支持与 Windows 上的 PowerShell 5.1 配合使用。 按照以下步骤安装模块:

  • 更新到 Windows PowerShell 5.1。 如果使用的是 Windows 10 版本 1607 或更高版本,则已安装 PowerShell 5.1。

  • 安装 .NET Framework 4.7.2 或更高版本。

  • 运行以下命令以安装最新的 PowerShellGet:

    Install-Module -Name PowerShellGet -Force -AllowClobber
    
  • 安装 Teams PowerShell 模块。

    Install-Module -Name MicrosoftTeams -Force -AllowClobber
    

脱机安装

在某些环境中,无法连接到PowerShell 库。 在这些情况下,请按照这些 手动安装步骤进行操作

登录

若要开始使用 Microsoft Teams PowerShell 模块,请使用 Azure 凭据登录。

Connect-MicrosoftTeams

更新 Teams PowerShell 模块

若要更新任何 PowerShell 模块,应使用用于安装模块的相同方法。 例如,如果最初使用 Install-Module,则应使用 Update-Module 获取最新版本。

Update-Module MicrosoftTeams

警告

如果 Teams PowerShell 已导入 PowerShell 会话,更新模块将失败。 关闭 PowerShell 并重新打开新的提升的 PowerShell 会话。

卸载 Teams PowerShell

若要卸载 Microsoft Teams PowerShell,请打开新的 PowerShell 命令提示符并运行以下命令:

Uninstall-Module MicrosoftTeams

# Uninstall all versions of the module
Uninstall-Module MicrosoftTeams -Allversions

后续步骤

现在,你已准备好使用 Microsoft Teams PowerShell 管理 Microsoft Teams。 请参阅 使用 Teams PowerShell 管理 Teams 以开始使用。

使用 Teams PowerShell 管理 Teams

Teams PowerShell 发行说明

Microsoft Teams cmdlet 参考