# Adding variable to table output

**URL:** <https://forums.powershell.org/t/adding-variable-to-table-output/23828>\
**Category:** PowerShell Help\
**Created:** [March 21, 2024, 4:54pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828 "2024-03-21T16:54:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattps7](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mattps7](https://forums.powershell.org/u/mattps7)\
**Post date:** [March 21, 2024, 4:54pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828/1 "2024-03-21T16:54:03Z")

</div>

Hi,

I am new to PowerShell and still learning as I go. I am trying to generate a M365 license report and need to be able to out a variable and a command output to the same table, so I can export it to csv. I’ve tried every combination but half the battle is know what the correct term to search Google with! 🙂

I am trying to insert the contents of $usr into the table output here:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/6/6265062c14085450ff493acddbcd37f02f33574f.png)

Any clues on what I need to google?

---

<div class="post-metadata">

**Author:** ![neemobeer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/neemobeer/32/4087_2.png) [@neemobeer](https://forums.powershell.org/u/neemobeer)\
**Post date:** [March 21, 2024, 6:06pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828/2 "2024-03-21T18:06:20Z")

</div>

Just throw it in another calculated property at the end

```auto
@{n="UserID";e={$usr}}

```

---

<div class="post-metadata">

**Author:** ![mattps7](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mattps7](https://forums.powershell.org/u/mattps7)\
**Post date:** [March 21, 2024, 6:09pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828/3 "2024-03-21T18:09:35Z")

</div>

Hero! Thank you very much. So that is called a “calculated property”.

---

<div class="post-metadata">

**Author:** ![neemobeer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/neemobeer/32/4087_2.png) [@neemobeer](https://forums.powershell.org/u/neemobeer)\
**Post date:** [March 21, 2024, 6:16pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828/4 "2024-03-21T18:16:43Z")

</div>

Yup yup.

> **[about Calculated Properties - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_calculated_properties?view=powershell-7.4)**
>
> PowerShell provides the ability to dynamically add new properties and alter the formatting of objects output to the pipeline.

---

<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:** [April 20, 2024, 6:17pm UTC](https://forums.powershell.org/t/adding-variable-to-table-output/23828/5 "2024-04-20T18:17:02Z")

</div>

Closed on April 20, 2024, 6:17pm UTC

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