Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 %{} ?

like image 962
Frank im Wald Avatar asked Feb 08 '16 14:02

Frank im Wald


1 Answers

%{ $_.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.

like image 199
Ansgar Wiechers Avatar answered Nov 03 '22 20:11

Ansgar Wiechers