I need add a column in a output of command.
The comand run on a terminal service and get the status of users
$users = Invoke-Command -ScriptBlock {query user} $users | Out-File c:\users.txt
The output of “query user” is:
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME user1 rdp-tcp#1 272 Active 3 18/11/2016 04:09 user2 rdp-tcp#24 277 Active 1:59 18/11/2016 06:05
But I need include a collumn with the datetime when command is run, see:
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME EXEC TIME user1 rdp-tcp#1 272 Active 3 18/11/2016 04:09 11:00 user2 rdp-tcp#24 277 Active 1:59 18/11/2016 06:05 11:00
I have tried to use “$users | Add-Member NoteProperty IName($fiel.Hour)” in command, but not works…