Providing Free and Editor Tested Software Downloads
< HOME | TUTORIALS | GEEK-CADE| WEB TOOLS | YOUTUBE | NEWSLETTER | DEALS! | FORUMS | >

MajorGeeks.com - Have you hugged a Geek today?

Software Categories

All In One Tweaks
Android
Antivirus & Malware
Appearance
Back Up
Browsers
CD\DVD\Blu-Ray
Covert Ops
Drivers
Drives (SSD, HDD, USB)
Games
Graphics & Photos
Internet Tools
Linux Distros
MajorGeeks Windows Tweaks
Multimedia
Networking
Office & Productivity
System Tools

Other news

· How To and Tutorials
· Life Hacks and Reviews
· Way Off Base
· MajorGeeks Deals
· News
· Off Base
· Reviews




spread the word

· YouTube
· Facebook
· Instagram
· Twitter
· Pintrest
· RSS/XML Feeds
· News Blur
· Yahoo
· Symbaloo

about

· Top Freeware Picks
· Malware Removal
· Geektionary
· Useful Links
· About Us
· Copyright
· Privacy
· Terms of Service
· How to Uninstall

top downloads

1. GS Auto Clicker
2. Smart Defrag
3. Macrium Reflect FREE Edition
4. Sergei Strelec's WinPE
5. MusicBee
6. Visual C++ Redistributable Runtimes AIO Repack
7. K-Lite Mega Codec Pack
8. ImgBurn
9. Unlocker
10. FlyOobe / Flyby11
More >>

top reads

Star 8 Windows Shortcuts That’ll Make You More Productive and Save You Time

Star Windows 10 Not Dead Yet - You Can Still Get Updates For Free

Star What is a '400 Bad Request - Request Header or Cookie Too Large' Error and How to Fix It

Star How to Fix Windows Install Error 0xC1900101

Star How to Force Enable Windows 10 Extended Security Updates If The Option Is Not Showing

Star Windows 11 25H2 is Out: What’s New and How to Get It Now.

Star Star Trek Fleet Command Promo Codes: Redeem Codes for Free Shards, Blueprints And Resources

Star Boost Your PC Speed with ReadyBoost: How a Thumb Drive Can Enhance Your System's Performance

Star 5 Hidden Windows Tools You’ve Had All Along But Never Use

Star Use the Windows 10 Media Creation Tool Before Support Ends For Windows 10 in 2025


MajorGeeks.Com » Overview» Tutorials and Video Guides » How to View, Save, and Clear Your PowerShell and Command Prompt History

How to View, Save, and Clear Your PowerShell and Command Prompt History

By Timothy Tibbetts

on 06/15/2023

🎃🧟‍♂️👻 IObit’s Spooktacular Halloween Sale! IObit Halloween Sale: 90% OFF + Mystery Treat 🍬
Experience faster surfing, smarter security, and total privacy with IObit Pro!

Both the Command Prompt and PowerShell can show you the history of all commands during the current session. In this guide, we show you not only how to how to view your history but other options including how to clear and save your current Command Prompt or PowerShell session.

Command Prompt

The Command Prompt history can be viewed by typing in doskey /history, or our favorite quick way, pressing the F7 button. If you use the F7 method, press the ESC key to close.



You can save your history by typing in doskey /HISTORY > SampleHistory.txt replacing. TXT with the supported file types including TXT, HTML, CSV or RTF.

Clearing your current history is as simple as closing the Command Prompt, since, as we mentioned, only your current session is saved. You can also press Alt+F7 to clear your history without closing the Command Prompt.

-=- Advertisement -=-

Reimage download TIP: Hard to fix Windows Problems? Repair/Restore Missing Windows OS Files Damaged by Malware with a few clicks



PowerShell

PowerShell, as always, is better and features many more options. One of the best thing about PowerShell is that it saves the last 4,096 typed commands automatically in %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt. Unlike the Command Prompt, this list is saved even if you close PowerShell.

You can see all the command from your current session only by typing in Get-History. Optionally, you can type in Get-History | Format-List -Property * to see more information including the start and end times and command status.



You can also search for a command by typing in CTRL+R (reverse search) or CTRL+S (forward search) and begin typing in the command you're looking for.

To clear your history or see the options we mentioned, you can type in Get-PSReadlineKeyHandler | ? {$_.function -like '*hist*'}. Like the Command Prompt, Alt+F7 also works will if you want to clear the current session history.



Unlike the Command Prompt, we discussed where your PowerShell history is saved. If you'd like to clear that text file, type in Remove-Item (Get-PSReadlineOption).HistorySavePath. ConsoleHost_history.txt will be deleted and recreated the next time you type a command into Powershell.

You can also export your current session to an XML file by typing in Get-History | Export-Clixml -Path c:\ps\commands_hist.xml.

Similar:
  • The Ultimate List of Every Known Command Prompt and PowerShell Commands
  • PowerShell and Command Prompt 101
  • How-To Run PowerShell or the Command Prompt as Administrator
  • What's the Difference Between PowerShell and PowerShell Core?
  • PowerShell Data Execution Policies Explained

    comments powered by Disqus





  • © 2000-2025 MajorGeeks.com
    Powered by Contentteller® Business Edition