{"id":15637,"date":"2020-03-15T12:39:20","date_gmt":"2020-03-15T12:39:20","guid":{"rendered":"https:\/\/www.top-password.com\/blog\/?p=15637"},"modified":"2020-03-15T12:39:20","modified_gmt":"2020-03-15T12:39:20","slug":"see-command-history-from-powershell-sessions","status":"publish","type":"post","link":"https:\/\/www.top-password.com\/blog\/see-command-history-from-powershell-sessions\/","title":{"rendered":"How to See Command History from Previous PowerShell Sessions in Windows 10"},"content":{"rendered":"<p>Is there a way to see command line history across all PowerShell sessions? Windows PowerShell lets you view every command you&#8217;ve executed during the current session by using the <code>Get-History<\/code> command. But sometimes that is not enough. In this tutorial we&#8217;ll show you how to see the full command history from all previous sessions in Windows 10.<\/p>\n<p><strong>How to See Command History from Previous PowerShell Sessions in Windows 10<\/strong><\/p>\n<ol>\n<li>In order to use the PowerShell command history functionality, you need to first install the <strong>PSReadLine<\/strong> module with the below command.<br \/>\n<code>Install-Module PSReadLine<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/install-PSReadLine.png\" alt=\"\" width=\"503\" height=\"299\" class=\"alignnone size-full wp-image-15643\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/install-PSReadLine.png 503w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/install-PSReadLine-300x178.png 300w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/p>\n<p> \tIf you&#8217;re prompted to install <strong>NuGet Provider<\/strong>, type <strong>Y<\/strong> and press Enter.<\/li>\n<li>Next, type the following command to display the path to the file in which the PowerShell command history is saved.<br \/>\n<code>(Get-PSReadlineOption).HistorySavePath<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/view-powershell-command-history-1.png\" alt=\"\" width=\"538\" height=\"251\" class=\"alignnone size-full wp-image-15645\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/view-powershell-command-history-1.png 538w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/view-powershell-command-history-1-300x140.png 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/p>\n<p> \tTo view the full detailed command history on the PowerShell console, run this command:<br \/>\n<code>cat (Get-PSReadlineOption).HistorySavePath<\/code><\/li>\n<li>To clear all the history of PowerShell commands you&#8217;ve ever typed, type the following command:<br \/>\n<code>Remove-Item (Get-PSReadlineOption).HistorySavePath<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/clear-powershell-command-history.png\" alt=\"\" width=\"545\" height=\"140\" class=\"alignnone size-full wp-image-15646\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/clear-powershell-command-history.png 545w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/clear-powershell-command-history-300x77.png 300w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/p>\n<p> \tIf you need to prevent PowerShell from saving command history, execute this command:<br \/>\n<code>Set-PSReadlineOption -HistorySaveStyle SaveNothing<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/disable-powershell-command-history.png\" alt=\"\" width=\"544\" height=\"138\" class=\"alignnone size-full wp-image-15647\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/disable-powershell-command-history.png 544w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2020\/03\/disable-powershell-command-history-300x76.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/p>\n<p> \tWhenever you want to configure PowerShell to track all executed commands again, run the following command:<br \/>\n<code>Set-PSReadlineOption -HistorySaveStyle SaveIncrementally<\/code>\n<\/li>\n<\/ol>\n<p>That&#8217;s it!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Is there a way to see command line history across all PowerShell sessions? Windows PowerShell lets you view every command you&#8217;ve executed during the current session by using the Get-History command. But sometimes that is not enough. In this tutorial we&#8217;ll show you how to see the full command history from all previous sessions in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,10,1894],"tags":[4432,4433,4431],"class_list":["post-15637","post","type-post","status-publish","format-standard","hentry","category-others","category-tips-tricks","category-windows-10","tag-powershell-history-command","tag-powershell-run-command-from-history","tag-see-powershell-command-history"],"_links":{"self":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/15637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/comments?post=15637"}],"version-history":[{"count":6,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/15637\/revisions"}],"predecessor-version":[{"id":15649,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/15637\/revisions\/15649"}],"wp:attachment":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/media?parent=15637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/categories?post=15637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/tags?post=15637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}