共用方式為


什麼是 Azure PowerShell?

Azure PowerShell 是用於管理 Azure 資源的正式 Microsoft PowerShell 模組集合的產品名稱。 它需要 PowerShell,一種命令列 shell 和腳本語言。

您可以從 PowerShell 執行命令,或建立和執行包含多個命令的指令碼,以互動方式使用 Azure PowerShell。

Az PowerShell 模組

目前版本的 Azure PowerShell 是 Az PowerShell 模組。 這是建議的 PowerShell 模組,用於在所有平臺 (包括 Windows、Linux 和 macOS) 上使用 PowerShell 管理 Azure 資源。 它包含數千個命令,可控制 Azure 的幾乎每個層面。 Az PowerShell 模組是跨平臺的。

備註

PowerShell 7 或更新版本是建議與 Az PowerShell 模組搭配使用的 PowerShell 版本。 它也與 Windows PowerShell 5.1 相容。

使用 Az PowerShell 模組有幾個不同的選項:

  • Azure Cloud Shell:一種基於瀏覽器的 shell,允許您運行 Azure PowerShell 命令,而無需在本機計算機上安裝任何內容。
  • 本機安裝:若要直接從終端機執行命令,請在本機電腦上安裝 Azure PowerShell。
  • Docker 容器:在 Docker 容器中執行 Azure PowerShell。

Authentication

Azure PowerShell 支援數種驗證方法。 如需從 Az PowerShell 模組向 Azure 進行驗證的詳細資訊,請參閱 從 Azure PowerShell 登入 Azure

模組設計

Az PowerShell 模組是 Azure 服務相關 PowerShell 模組的包裝函式模組,通常每個 Azure 服務都有一個模組,例如適用於 Azure 網路服務的 Az.Network 和適用於 Azure Kubernetes 服務的 Az.Aks

Az PowerShell 模組中的 Cmdlet 會對 Azure Resource Manager API 進行 REST 呼叫。 Az PowerShell 模組中的重大變更限制為每年兩次。 API 層級的許多重大變更都會在 Cmdlet 內處理,以防止感知重大變更。

Az PowerShell 模組包含 Cmdlet,可在 Azure 中執行控制平面和資料平面作業。 您可以使用控制平面來管理您訂用帳戶中的資源。 您可以使用資料平面來控制資源類型執行個體所公開的功能。 如需詳細資訊,請參閱 Azure 控制平面和資料平面

輸出物件

Az PowerShell 模組中的 Cmdlet 會產生 .NET 物件。 如同任何產生輸出的 PowerShell 命令, Az PowerShell 模組中的 Cmdlet 可以透過管道傳送至 Get-Member Cmdlet,以判斷所產生的物件類型,以及可用屬性和方法的清單。 如需詳細資訊,請參閱 Azure PowerShell 的查詢輸出格式化 Azure PowerShell Cmdlet 輸出

AzPreview PowerShell 模組

AzPreview PowerShell 模組包含來自 Az PowerShell 模組的所有正式發行 (GA) 模組,以及用於管理 Azure 資源的所有預覽模組。 不建議在生產環境中使用,因為預覽模組不遵守重大變更原則。

AzPreview 模組一律是相同的版本,而且會與 Az PowerShell 模組同時發行。

AzureRM PowerShell 模組

雖然您可能會在線上找到使用 AzureRM PowerShell 模組的範例,但它是上一代的 Azure PowerShell。 它已被取代,不再維護或支援,也不建議使用。 AzureRM PowerShell 模組中的命令會使用格式。*-AzureRM* 如需詳細資訊,請參閱 AzureRM PowerShell 模組概觀

Azure PowerShell 模組

您可能也會遇到名為 Azure PowerShell 模組的 Azure PowerShell 版本。 此模組可用來管理使用 Azure Service Manager (ASM) API 的舊版 Azure 資源。 不建議建立新資源,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure PowerShell 服務管理模組概觀

這些產品可用來管理 Azure 資源,但不是 Azure PowerShell 集體產品的一部分。 絕不應該使用 「Azure PowerShell」 集合名稱來描述它們。

  • Azure Active Directory PowerShell (AzureAD)
  • Azure 資訊保護 PowerShell
  • Azure 部署管理員 PowerShell
  • Azure 彈性資料庫作業 PowerShell
  • Azure Service Fabric PowerShell
  • Azure Stack PowerShell
  • Microsoft.Graph PowerShell
  • Microsoft.Graph.Entra PowerShell
  • MSOnline PowerShell

指導方針

  • 一律使用產品的完整適當名稱或特定的 PowerShell 模組名稱

參考資料

Get-Member