Select statement in Powershell

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.

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

You simply add them to the list of porperties!? :man_shrugging:t4: … or did I get something wrong?

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?

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

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

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

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

… output …

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

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

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.

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