I want to list entered commands in Windows PowerShell with their respective timestamps. How can I do it with Get-History
command?
Asked
Active
Viewed 8,750 times
8

Andrew Schulman
- 8,811
- 21
- 32
- 47

Ramin Omrani
- 197
- 1
- 5
-
4A bit late, but as a senior systems engineer, I'd like to note that this kind of question is very ON TOPIC for "managing information technology systems in a business environment." It is unfortunate that it was deemed off-topic and closed. This could have led to a great post (possibly wiki) about session transcription and about change management processes on servers. The question may not be written exceptionally well, but the topic is certainly there! – SamErde Feb 22 '16 at 14:08
-
One of the many hats I wear in our small technology company is systems administration. When working out how to do some new administrative task, I often perfect the process in a shell and then keep the history with time stamps as the start of the documentation of this new task. In a bash shell I always have HISTTIMEFORMAT set. I needed to do this exact thing in PowerShell and now I know that: get-history | format-table -property EndExecutioTime, CommandLine does what I need. If that's not "managing IT systems in a business environment" I don't know what is! – lcbrevard Apr 30 '17 at 17:06
1 Answers
12
get-history |fl
gets you the command line and the start/end times of execution. But this is only shows you the history of commands which were entered in this specific powershell session, history does not seem to be retained. So if you restarted your computer I don't expect a lot of usefull output from get-history
I am not sure what method you're using to access those URLs but unless there is some additional logging in that method I don't think you're going to find the history.

Bert Neef
- 316
- 1
- 5
-
1`fl` means `format-list` As soon as I can answer, I would add infos from [this](https://www.howtogeek.com/298244/how-to-use-your-command-history-in-windows-powershell) which explains to export and import history data. It is xml based, which is a shame for 2020. – Timo Dec 25 '20 at 14:44
-
1@Timo I don't know why you think XML "is a shame", but if you prefer CSV you can just substitute `Export-Csv` and `Import-Csv` for `Export-Clixml` and `Import-Clixml`. – Massimo Dec 25 '20 at 18:50
-
@Massimo,thanks I prefer json in 2021 which seems to be [better](https://blog.cloud-elements.com/json-better-xml), of course this is somehow opinionated. – Timo Jan 03 '21 at 08:25