Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/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/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
在powershell中如何访问当前对象属性_Powershell_Azure - Fatal编程技术网

在powershell中如何访问当前对象属性

在powershell中如何访问当前对象属性,powershell,azure,Powershell,Azure,第一个和第二个$\名称是容器的名称。对于每个容器,我想过滤掉容器中文件的名称,因此在Where对象中,我使用$\名称,我假设它是文件的名称,但是$\名称。始终引用容器的名称而不是文件名。如何按文件名进行筛选 $containers = Get-AzureStorageContainer -Context $ctx $containers|ForEach-Object{ Write-Host 'Container: ' $_.Name $fileName = Get-

第一个和第二个$\名称是容器的名称。对于每个容器,我想过滤掉容器中文件的名称,因此在Where对象中,我使用$\名称,我假设它是文件的名称,但是$\名称。始终引用容器的名称而不是文件名。如何按文件名进行筛选

$containers = Get-AzureStorageContainer -Context $ctx

    $containers|ForEach-Object{

    Write-Host 'Container: ' $_.Name

    $fileName = Get-AzureStorageBlob -Context $ctx -Container $_.Name|Where-Object {$_.Name -contains '.vhd'}    

    }

如果需要在循环内执行多个操作,我建议您避免使用类似$containers | ForEach对象的语法

尝试在$containers中使用foreach$container插入insead,这样您的代码将类似于

foreach ($container in $containers) {
    Write-Host 'Container: ' $container.Name
    $fileName = Get-AzureStorageBlob -Context $ctx -Container $container.Name | Where-Object {$_.Name -contains '.vhd'}
}