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

Fra*_*ald 11 powershell hdinsight

在为HDInsight编程时,我遇到了类似的行

$storageAccountKey = Get-AzureRmStorageAccountKey 
    -ResourceGroupName $resourceGroupName 
    -Name $storageAccountName 
    |  %{ $_.Key1 }
Run Code Online (Sandbox Code Playgroud)

我理解$_是指Get-AzureRmStorageAccountKey命令的结果.但究竟是什么意思%{}

Ans*_*ers 25

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

%是一个别名ForEach-Object.$_是当前对象的自动变量.