# Select statement in Powershell

**URL:** <https://forums.powershell.org/t/select-statement-in-powershell/20206>\
**Category:** PowerShell Help\
**Created:** [August 19, 2022, 1:01pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206 "2022-08-19T13:01:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomlon](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tomlon](https://forums.powershell.org/u/tomlon)\
**Post date:** [August 19, 2022, 1:01pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/1 "2022-08-19T13:01:51Z")

</div>

I have the following statement that will be used to output the data to an export file. How can I add three additional column headers? These headers do not correspond to any data from the script; I just need the headers in the file. They will be at the end (after L2MgrDept) and like to be labeled 30Days, 60Days, 90Days.

```auto
Select-Object sAMAccountName, Name, Mail, UsrDept, Enabled, Manager, ManagerEmail, MgrDept, L2Manager, L2ManagerEmail, L2MgrDept | Sort-Object -Property sAMAccountName -Unique

```

---

<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:** [August 19, 2022, 1:10pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/2 "2022-08-19T13:10:10Z")

</div>

> [@tomlon](#):
>
> How can I add three additional column headers?

You simply add them to the list of porperties!? 🤷🏽‍♂️ … or did I get something wrong?

---

<div class="post-metadata">

**Author:** ![tomlon](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tomlon](https://forums.powershell.org/u/tomlon)\
**Post date:** [August 19, 2022, 2:07pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/3 "2022-08-19T14:07:41Z")

</div>

Well, I had attempted to add it as a property (Still learning PSCUSTOMOBJECT) . The properties I was trying to add was 30Days, 60Days, 90Days, 180Days. Kept getting flagged ‘Unexpected token ‘30Days’ in expression or statement.’ for each one. I believe that I just learned that properties can not begin with an integer, as I flipped them (Days30, Days60, Days90, etc) and it is accepting them. Is my assumption correct in this?

---

<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:** [August 19, 2022, 2:19pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/4 "2022-08-19T14:19:01Z")

</div>

> [@tomlon](#):
>
> Is my assumption correct in this?

I’ve never thought about it but it sounds reasonable. And I couldn’t find an according info in the help

> **[about Properties - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_properties?view=powershell-7.2)**
>
> Describes how to use object properties in PowerShell.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [August 19, 2022, 2:24pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/5 "2022-08-19T14:24:31Z")

</div>

Did you quote the properties? That’s what I’d guess was missing

---

<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:** [August 19, 2022, 2:28pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/6 "2022-08-19T14:28:34Z")

</div>

Actually I don’t have any problems using property names with integers … I don’t get any error

```auto
Get-Process -Name powershell |
    Select-Object -Property Description, CPU, Bla, 30Bla, 60Bla

```

… output …

```auto
Description : Windows PowerShell
CPU : 36,71875
Bla :
30Bla :
60Bla :

Description : Windows PowerShell
CPU : 2,0625
Bla :
30Bla :
60Bla :

```

---

<div class="post-metadata">

**Author:** ![tomlon](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tomlon](https://forums.powershell.org/u/tomlon)\
**Post date:** [August 19, 2022, 2:33pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/7 "2022-08-19T14:33:33Z")

</div>

I believe that I may have an issue with VSCode. It is actually flagging it in VSCode (I didnt run it, just seeing the error notation). I tried it in Notepad++, and no error, and it ran fine. Thanks all.

---

<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:** [August 19, 2022, 2:35pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/8 "2022-08-19T14:35:19Z")

</div>

> [@tomlon](#):
>
> I believe that I may have an issue with VSCode

Just for your info - I use VSCode as well. And there are no flags … neither with PowerShell 5.1 nor PowerShell 7.2.6. 😉

---

<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:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/select-statement-in-powershell/20206/9 "2024-05-16T20:16:44Z")

</div>


