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