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中做到這一點?