# Trying to learn what this line of PS code does

**URL:** <https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563>\
**Category:** PowerShell Help\
**Created:** [February 8, 2024, 1:50pm UTC](https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563 "2024-02-08T13:50:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_argento3](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@a\_argento3](https://forums.powershell.org/u/a_argento3)\
**Post date:** [February 8, 2024, 1:50pm UTC](https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563/1 "2024-02-08T13:50:31Z")

</div>

Morning all,  
Somewhat new to PS and ran into a line of code that I do not understand; Line of code is this: $psData | %{‘{0}|{1}|{2}|{3}|{4}’ -f $_[0],$_[1],$_[2],$_[3],$\_[4] } \>\> “c:\users\johna\Elements.txt”

The pipe append to an folder and filename is clearly understood, as well as the piping of the input “$psData” variable, but what I’ve not been able to find is a description of %{‘{0}|{1}|{2}|{3}|{4}’ -f $_[0],$_[1],$_[2],$_[3],$\_[4] }  
Looking at the content of the Elements.txt it seems clear that the 0-4 are four ‘|’ values, but like to understand how it works.

Thanks

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [February 8, 2024, 1:54pm UTC](https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563/2 "2024-02-08T13:54:14Z")

</div>

Good morning and welcome!

When you have a moment, please go back and format your code: Formatting your code: [How to format code on PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 8, 2024, 2:29pm UTC](https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563/3 "2024-02-08T14:29:33Z")

</div>

Alex,

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you potentially wasting their time.

Thanks

> <https://stackoverflow.com/questions/77962388/found-this-bit-of-powershell-code-and-not-sure-what-this-variable-processing-doe>

You may start your research looking for the “PowerShell format operator `-f`”:

> **[about Operators - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.4#format-operator--f)**
>
> Describes the operators that are supported by PowerShell.

or here

[https://ss64.com/ps/syntax-f-operator.html](https://ss64.com/ps/syntax-f-operator.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [March 9, 2024, 2:29pm UTC](https://forums.powershell.org/t/trying-to-learn-what-this-line-of-ps-code-does/23563/4 "2024-03-09T14:29:43Z")

</div>

Closed on March 9, 2024, 2:29pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
