Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何匹配Powershell Azure虚拟机中的对象_Azure_Powershell_Azure Powershell_Azure Automation - Fatal编程技术网

如何匹配Powershell Azure虚拟机中的对象

如何匹配Powershell Azure虚拟机中的对象,azure,powershell,azure-powershell,azure-automation,Azure,Powershell,Azure Powershell,Azure Automation,我目前正在尝试匹配powershell中的一个对象,但得到的输出为空,我不知道为什么。任何指导都将不胜感激。我正在尝试将$resourceIDs与Get-AzVM命令匹配。ResourceId和“Get-AzVM.ID”的示例输出如下 /subscriptions/00/resourcegroups/rg-vm1/providers/microsoft.compute/virtualmachines/az-vm1 下面是我正在运行的获得空白输出的代码。将上面的字符串与下面的Get-AzVM命令

我目前正在尝试匹配powershell中的一个对象,但得到的输出为空,我不知道为什么。任何指导都将不胜感激。我正在尝试将$resourceIDs与Get-AzVM命令匹配。ResourceId和“Get-AzVM.ID”的示例输出如下

/subscriptions/00/resourcegroups/rg-vm1/providers/microsoft.compute/virtualmachines/az-vm1
下面是我正在运行的获得空白输出的代码。将上面的字符串与下面的Get-AzVM命令匹配是可行的,但是当我使用一个变量进行匹配时,会有空白输出

$resourceIDs =((Get-AzPolicyState -Filter "ComplianceState eq 'NonCompliant'" | Where-Object {$_.PolicyDefinitionReferenceId -eq "azure backup should be enabled for virtual machines_1"} | Where-Object {$_.SubscriptionId -eq ""}).resourceID)
Get-AzVM | Where-Object{$_.Id -match $resourceIDs}
编辑:传递
getazvm | Where对象{$\u0.Id-eq$resourceIDs[0]}
好了,现在我必须弄清楚如何循环使用所有$resourceIDs

编辑:
Get-AzVM | Where对象{$\ Id-in$resourceIDs}

非常感谢大家!

您可以使用循环


太棒了谢谢
$resourceIDs =((Get-AzPolicyState -Filter "ComplianceState eq 'NonCompliant'" | Where-Object {$_.PolicyDefinitionReferenceId -eq "azure backup should be enabled for virtual machines_1"} | Where-Object {$_.SubscriptionId -eq ""}).resourceID)

foreach ( $id in $resourceIDs) 

{

Get-AzVM | Where-Object{$_.Id -in $id}

}