0
我正在尝试获取特定VM的私有IP。我有这样的代码这是工作Powershell获取特定VM的私有IP
$vms = get-azurermvm -ResourceGroupName abc
$nics = get-azurermnetworkinterface -ResourceGroupName abc| where VirtualMachine -NE $null #skip Nics with no VM
foreach($nic in $nics)
{
$vm = $vms | where-object -Property Id -EQ $nic.VirtualMachine.id
$prv = $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAddress
Write-Output "$($vm.Name) : $prv"
}
我的VM名es-client-node1
,es-client-node2
,es-master-node1
,es-data-node1
& es-data-node1
。我想获得只是客户端节点的IP地址或虚拟机的名称匹配es-client-node*
,类似于datanode &主节点到不同的变量
任何想法如何在PowerShell中做到这一点?