Windows PowerShell - How to view commands history date/time

by Ramin   Last Updated January 14, 2018 12:01 PM

I want to list entered commands in Windows PowerShell with their respective timestamps. How can I do it with Get-History command?

Also if that isn't doable then please show me a way to check which urls(network) at which timestamps have been accessed through the CMD.

Also consider that I've restarted my computer.



Answers 3


As far as I'm aware, once you close a PowerShell console all history and logs are disposed.

You could check out something like: Giving PowerShell a Persistent History of Commands

Of course this won't retrieve anything you've already done, it will only start logging from the point you install it.

EDIT: PowerShell 5.0 appears to have implemented a persistent history, available even after restart, accessible via the usual ways.

Deadly-Bagel
Deadly-Bagel
November 16, 2015 15:36 PM

On Windows 10, the PS extension PsReadline comes with PowerShell 5 by default. Get-Content on the following to view your full command history.

C:\Users\username\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

To make it available on Windows 7, you have to make sure you have the latest Framework and PowerShell 5 installed. Then you can install the PsReadline module.

I just did on a Windows 7 (64) machine:

(executionpolicy : remotesigned)

Install-Module PSReadLine ( I was asked to install NuGet-anycpu.exe, and answered yes).

Import-Module PsReadLine

Your history will now be stored in the file mentionned above (verified)

Run Get-PSReadlineKeyHandler to have a list of PSReadline Key bindings.

Dan St-G
Dan St-G
October 07, 2016 16:06 PM

The Powershell history is saved in the file ConsoleHost_history.txt to find the location of the file execute this PS command:- (Get-PSReadlineOption).HistorySavePath

AcmeUK
AcmeUK
January 14, 2018 11:52 AM

Related Questions



Sensitive info in Powershell and/or cmd invocations

Updated August 31, 2015 19:00 PM