ForEach

De Linuxmemo.

Version du 14 décembre 2022 à 11:01 par Linuxmemo (discuter | contributions)
(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)

Commande

Methode

ForEach and Where methods

Both the ForEach and Where intrinsic methods for arrays take a scriptblock as an input parameter.

You can use the $PSItem in those scriptblocks to access the current object ("$PSItem" = "$_").

@('a', 'b', 'c').ForEach({ $PSItem.ToUpper() }).Where({ $PSItem -ceq 'B' })
Outils personnels