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

MajorGeeks.com - We put the Major in 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


Opera One
Everything
you need.
Already
there.
AI assistant
Aria, built right in
Free VPN
No account needed
Ad blocker
Faster, cleaner web
Tab Islands
Grouped browsing
Useful sidebars
Make it yours
No Clunky Extensions Needed.



MajorGeeks Approved.



Download free

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. K-Lite Mega Codec Pack
5. MusicBee
6. Microsoft Visual C++ 2015-2022 Redistributable Package
7. Sergei Strelec's WinPE
8. K-Lite Codec Pack Full
9. Visual C++ Redistributable Runtimes AIO Repack
10. McAfee Removal Tool (MCPR)
More >>

top reads

Star How Much Storage Space Are Your Installed Apps Using in Windows 11?

Star How To Reset and Fix the Settings App in Windows 11

Star How To Remove the Windows 11 Updated Start Menu

Star How To Download a Windows 11 ISO

Star How To Disable Drag Tray

Star How To Boot Into WinRE (Windows Recovery Environment)

Star How To Find the Installation Date of Apps

Star Recently Opened Files - How To Hide or Show Them In Jump Lists, File Explorer, and Start Menu

Star How To Change the Name of a Local or Microsoft Account

Star How To Remove OneDrive From the Navigation Pane in File Explorer


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

Hop into IObit’s Easter Sale and save up to 90% on top utilities, plus score 3 FREE months before the deal disappears! πŸ°πŸŒ·πŸ†

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-2026 MajorGeeks.com
    Powered by Contentteller® Business Edition