{"id":17733,"date":"2022-02-03T04:12:16","date_gmt":"2022-02-03T04:12:16","guid":{"rendered":"https:\/\/www.top-password.com\/blog\/?p=17733"},"modified":"2022-02-03T04:12:16","modified_gmt":"2022-02-03T04:12:16","slug":"view-command-history-in-powershell-or-command-prompt","status":"publish","type":"post","link":"https:\/\/www.top-password.com\/blog\/view-command-history-in-powershell-or-command-prompt\/","title":{"rendered":"Windows 11: How to View Command History in PowerShell or Command Prompt"},"content":{"rendered":"<p>Is there a simple way to see Command Prompt history without using arrow keys? Can I view PowerShell command history for previous sessions? In this tutorial we&#8217;ll show you how to quickly access the history of commands you recently typed in Windows Terminal (PowerShell or Command Prompt).<\/p>\n<p><strong>Part 1: View Command History in PowerShell<\/strong><\/p>\n<p>When you&#8217;re at the PowerShell console, just run the <code>history<\/code> command and it will display all commands you typed during the current session.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-command.png\" alt=\"\" width=\"592\" height=\"263\" class=\"alignnone size-full wp-image-17740\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-command.png 592w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-command-300x133.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\n<p>By default, PowerShell maintains the command history of all sessions and store it in a text file located in your user profile directory. Just press the <strong>Windows<\/strong> key + <strong>R<\/strong> together to launch the Run dialog, copy and paste the following path and press Enter:<br \/>\n<code>%userprofile%\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadline<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/run.png\" alt=\"\" width=\"399\" height=\"206\" class=\"alignnone size-full wp-image-17741\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/run.png 399w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/run-300x155.png 300w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/><\/p>\n<p>File Explorer will open to your specified location and you can see a text file named <code>ConsoleHost_history.txt<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/console-host-history.png\" alt=\"\" width=\"594\" height=\"290\" class=\"alignnone size-full wp-image-17742\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/console-host-history.png 594w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/console-host-history-300x146.png 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/p>\n<p>Open the <code>ConsoleHost_history.txt<\/code> file with NotePad and it reveals all the commands that you have typed in each PowerShell sessions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-of-all-sessions.png\" alt=\"\" width=\"499\" height=\"223\" class=\"alignnone size-full wp-image-17743\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-of-all-sessions.png 499w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/powershell-history-of-all-sessions-300x134.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/p>\n<p><strong>Part 2: View Command History in Command Prompt<\/strong><\/p>\n<p>When you&#8217;re at the Command Prompt, just execute the below command and the command history for your current session will appear on the screen.<br \/>\n<code>doskey \/history<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/doskey-command.png\" alt=\"\" width=\"592\" height=\"187\" class=\"alignnone size-full wp-image-17744\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/doskey-command.png 592w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/doskey-command-300x95.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\n<p>or press <strong>F7<\/strong> key to open a pop-up inside the Command Prompt, which shows a list of the commands that have been entered in this session. You can use the up and down arrow keys to select a command, and then press Enter to execute the command again.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/command-prompt-f7.png\" alt=\"\" width=\"592\" height=\"225\" class=\"alignnone size-full wp-image-17745\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/command-prompt-f7.png 592w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/command-prompt-f7-300x114.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\n<p>Once you close the Command Prompt window, the history will be removed permanently. Before closing it, you can use the following command to save the command history:<br \/>\n<code>doskey \/history > d:\\MyHistory.txt<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/save-command-prompt-history.png\" alt=\"\" width=\"592\" height=\"130\" class=\"alignnone size-full wp-image-17746\" srcset=\"https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/save-command-prompt-history.png 592w, https:\/\/www.top-password.com\/blog\/wp-content\/uploads\/2022\/02\/save-command-prompt-history-300x66.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\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 simple way to see Command Prompt history without using arrow keys? Can I view PowerShell command history for previous sessions? In this tutorial we&#8217;ll show you how to quickly access the history of commands you recently typed in Windows Terminal (PowerShell or Command Prompt). Part 1: View Command History in PowerShell When [&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,4713],"tags":[4807,4808,4809],"class_list":["post-17733","post","type-post","status-publish","format-standard","hentry","category-others","category-tips-tricks","category-windows-11","tag-powershell-command-history","tag-view-command-prompt-history","tag-windows-terminal-command-history"],"_links":{"self":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/17733","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=17733"}],"version-history":[{"count":14,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/17733\/revisions"}],"predecessor-version":[{"id":17754,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/posts\/17733\/revisions\/17754"}],"wp:attachment":[{"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/media?parent=17733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/categories?post=17733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.top-password.com\/blog\/wp-json\/wp\/v2\/tags?post=17733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}