ForEach
De Linuxmemo.
(Différences entre les versions)
(Page créée avec « Catégorie:PowerShell ==Commande== ==Methode== ForEach and Where methods Both the ForEach and Where intrinsic methods for arrays take a scriptblock as an input paramete... ») |
(→Methode) |
||
Ligne 9 : | Ligne 9 : | ||
You can use the $PSItem in those scriptblocks to access the current object ("$PSItem" = "$_"). | You can use the $PSItem in those scriptblocks to access the current object ("$PSItem" = "$_"). | ||
@('a', 'b', 'c').ForEach({ $PSItem.ToUpper() }).Where({ $PSItem -ceq 'B' }) | @('a', 'b', 'c').ForEach({ $PSItem.ToUpper() }).Where({ $PSItem -ceq 'B' }) | ||
+ | |||
+ | expression syntax: { $PSItem } |
Version actuelle en date du 14 décembre 2022 à 11:03
[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 }