如何使用 PowerShell 获取 Azure 虚拟机磁盘加密设置?

powershellmicrosoft technologiessoftware & coding更新于 2026/2/12 22:37:17

要使用 PowerShell 获取 Azure 磁盘加密设置,我们首先需要使用 Get-AzVM 命令检索虚拟机信息。运行此命令之前,请确保您已连接到 Azure 帐户 (Connect-AzAccount) 和正确的订阅 (Set-AzContext)。

在此示例中,我们有一个 TestVM。

$vm = Get-AzVM -Name TestVM

我们将使用 StorageProfile 属性和 OSdisk 子属性来获取加密设置。

$vm.StorageProfile.OsDisk.EncryptionSettings

上述命令将检索 Azure VM 磁盘加密的加密设置。

要检索特定订阅用途的所有 Azure VM 磁盘加密,

Get-AzVM | Select Name, ResourceGroupName,
@{N='Disk_Encryption';E={$_.StorageProfile.OSDisk.EncryptionSettings}}

相关文章