如何使用 PowerShell 获取 Azure 虚拟机的应用程序安全组?

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

要使用 PowerShell 获取 Azure 虚拟机的应用程序安全组,我们首先需要获取 Azure 虚拟机的网络接口。

以下命令将检索 Azure 虚拟机的网卡名称。

PS C:\> $vm = Get-AzVM -Name TestVM
$nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]

获取网卡名称后,我们可以使用 Get-AzNetworkInterface 命令检索网卡信息和安全组。

以下命令将使用 PowerShell 检索应用程序安全组名称。

PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nic
$nicsettings.IpConfigurations.ApplicationSecurityGroups

相关文章