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

MajorGeeks.com - Major tweaks for Major 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




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. Smart Defrag
4. Rufus
5. Visual C++ Runtime Installer (All-In-One)
6. McAfee Removal Tool (MCPR)
7. MusicBee
8. Sergei Strelec's WinPE
9. K-Lite Mega Codec Pack
10. Microsoft Visual C++ 2015-2022 Redistributable Package
More >>

top reads

Star How to Disable 1-Click Ordering on Amazon (and Avoid Surprise Charges)

Star How to Fix Shallow Paint Layer Depth in Bambu Studio

Star Aviator Betting Game Secrets: Unlock 97% RTP & Triple Your Wins

Star Windows Recall: What It Is, Why Hackers Will Love It, and How to Stay Safe

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

Star How To Use VLC Media Player to Trim Video Clips

Star What Is the $WinREAgent Folder and Can I Delete It?

Star Swear Your Way to Better Search Results

Star How to Get a Dark Start Menu and Taskbar in Windows 10 & 11

Star Enable, Disable, Manage, Delete or Create a System Restore Point


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

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