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

MajorGeeks.com - The Few, The Proud, The Geeks.

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



IObit Black Friday Sale

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. Macrium Reflect FREE Edition
3. Format Factory
4. Smart Defrag
5. Microsoft Visual C++ 2015-2022 Redistributable Package
6. MusicBee
7. Sergei Strelec's WinPE
8. FrostWire
9. Tweaking.com - Windows Repair
10. Fortect
More >>

top reads

Star Lossless vs Lossy: When FLAC, APE, and ALAC Beat MP3 and When They Don't

Star Google Search Tricks You'll Actually Use in 2025 and Beyond

Star Fresh PC Checklist: First 12 Things to Do On a New Windows 11 Machine

Star Running AI Models Locally: What They Are, Where to Find Them, and How to Get Started

Star Deciding Between Idle State, Sleep Mode, and Shutdown: What's Best for Your PC?

Star How to Fix VMware Workstation "The Update Server Could Not Be Resolved" Error Installing VMware Tools

Star How to Remove Google Gemini from Your Phone (and Your Life)

Star Windows Bloat Removal Guide: Debloat Safely and Keep What You Need

Star Windows 11 Repair Playbook: SFC, DISM, CHKDSK Without Breaking Stuff

Star Gmail Using Your Emails and Attachments for AI Training: Here's How To Opt Out


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

⚡ Black Friday Blowout! IObit Pro Up to 90% Saving PLUS $5 off! ⚡
Once-a-year pricing on speed, privacy, and protection. Don’t miss the best deal IObit drops all year!

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