Home Ask Login Register

Developers Planet

Your answer is one click away!

Frank im Wald February 2016

What does %{ $_.Key1 } mean?

While programming for HDInsight I came across lines like

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

I understand $_ refers to the result of the Get-AzureRmStorageAccountKey command. But what exactly is the meaning of %{} ?


Ansgar Wiechers February 2016

%{ $_.Key1 }ForEach-Object { Write-Output $_.Key1 } ⇔ for each object in the pipeline, echo the value of its property Key1.

% is an alias for ForEach-Object. $_ is the current object automatic variable.

Post Status

Asked in February 2016
Viewed 3,756 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life