ForEach

De Linuxmemo.

[modifier] Commande

[modifier] 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' })
expression syntax: { $PSItem }
Outils personnels