Author Posts

August 17, 2017 at 1:32 pm

Hello all users of this forum,
I'm new here and powershell too:)

I write a simple code to list open file on the file server:

 get-smbopenfile | Where-object -property path -like "*com*" | ft ClientUsername, path -wrap -autosize 

but I need also an actual date and time in additional column, I'm trying as below but it didn't work

 get-smbopenfile | Where-object -property path -like "*com*" | ft ClientUsername, path, get-date -wrap -autosize 

Can I ask for any suggestions?
Thx

August 17, 2017 at 1:43 pm

You're close. There's actually an example of the correct syntax in the help for Format-Table. It's Example 5 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-table?view=powershell-5.1

August 17, 2017 at 1:58 pm

get-smbopenfile | Where-object -property path -like "*com*" | ft ClientUsername, path, @{Label="time"; Expression={(Get-Date) }} -wrap -autosize 

Thx Mr Don Jones it did the job