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