Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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 %{$\.Key1}是什么意思?_Powershell_Azure Hdinsight - Fatal编程技术网

Powershell %{$\.Key1}是什么意思?

Powershell %{$\.Key1}是什么意思?,powershell,azure-hdinsight,Powershell,Azure Hdinsight,在为HDInsight编程时,我遇到了如下几行 $storageAccountKey = Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName | %{ $_.Key1 } 我知道$\uuz指的是Get-AzureRmStorageAccountKey命令的结果。但是%{}的确切含义是什么呢?%{$\u.Key1}⇔ ForEach

在为HDInsight编程时,我遇到了如下几行

$storageAccountKey = Get-AzureRmStorageAccountKey 
    -ResourceGroupName $resourceGroupName 
    -Name $storageAccountName 
    |  %{ $_.Key1 }

我知道
$\uuz
指的是
Get-AzureRmStorageAccountKey
命令的结果。但是
%{}
的确切含义是什么呢?

%{$\u.Key1}
ForEach对象{Write Output$\.Key1}
⇔ 对于管道中的每个对象,回显其属性值
Key1


%
是一个for
$\
是当前对象。

事实上,
$storageAccountKey=Get-AzureRmStorageAccountKey-ResourceGroupName$ResourceGroupName-Name$storageAccountName |%{$\.Key1}
仅适用于PowerShell 1.3.2和早期版本

上述命令现在不起作用

请使用以下最新命令:

$storageAccountKey = Get-AzStorageAccountKey `
            -ResourceGroupName $storageAccountResourceGroupName `
            -Name $storageAccountName | Where-Object {$_.KeyName -eq "key1"} | %{$_.Value}