安裝 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 参照