• Home
  • About
  • Contact
  • Resources
  • News
  • Home
  • About
  • Contact
  • Resources
  • News
Powershell Newbie

Get | Set | Start

Play Hard, forget not

5/16/2017

0 Comments

 


As you are getting more familiar with the shell and begin to try more and more and more commands with more and more inputs and more and more parameters you might forget what you did 17 commands ago. Wait.. what was I saying.. Oh yeah. This is what get-history is for. Sure, you could hit the up arrow 17 times to get there. The nice thing about get-History is that it is like a map of where you and your thoughts have been. A map of how you got where you are. I have taken the history from some sessions I really want to remember the whole path of, and output them to a file for reference.
Try it.
Get-process
notepad.exe
Get-process
get-process notepad
get-process Notepad | stop-process
Get-history
Get-History | Out-File C:\users\youruser\history.txt

Great for referencing when you are starting out.

Note: In the newer versions of PowerShell you get to keep your history even after closing sessions. to get just the last 17 items for your history file add:
-count 17 after get-History
Example:
Get-History -Count 17

0 Comments



Leave a Reply.

    Joshua B. Jones, VCP6-DCV

    Professional PowerShell Fan, Automation & Virtualization Expert

    Archives

    February 2018
    January 2018
    December 2017
    November 2017
    May 2017
    August 2016

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.