I saw these two console tools for PowerShell in my newsfeed, and I like them 🙂 This blog post will show you what they are and how they work.
What is F7History?
In older PowerShell versions, pressing F7 gave you a list of previous commands you could select and run again. This option is no longer available in newer versions of PowerShell when using the PSReadline module, and that’s where F7History comes in. When using this module, it’s possible to show previous commands again using F7 instead of scrolling back with the Up-arrow and searching using Ctrl-R.
What is Out-ConsoleGridView?
In PowerShell, you have the option to output information to Out-GridView. This depends on PowerShell ISE (So, for everyone who removes that from Windows… Don’t 🙂 ). The Out-ConsoleGridView cmdlet does the same thing, but instead of popping a separate Window… It displays it inside your PowerShell terminal and has the excellent Filter option at the top.
The Out-ConsoleGridView cmdlet is dependent on the Microsoft.PowerShell.ConsoleGuiTools module. The F7History has a dependency on the Out-ConsoleGridView, PSReadline, and Microsoft.PowerShell.ConsoleGuiTools modules.
Note: Both are only available starting from PowerShell v7.2 because of the dependency on Microsoft.PowerShell.ConsoleGuiTools
You can add F7History to your system by installing the module by running the following:
To have it available in all your sessions, you can add this to your profile like this:
- Notepad $profile - Add Import-Module -Name "F7History" to the file - Quit/Save and start a new PowerShell session
After running import-module F7History, pressing F7 will show you this:
You can use the Up or Down arrow key to select a command from the list and press Enter to run that command again. If you use the Tab key, it will jump into the Filter line so that you can search for a specific command if the list of previous commands is too extensive.
But if you want to see all your history, you can press Shift-F7. This will look almost the same, but it will also tell you when you ran a specific command:
If you want to read more about F7History, follow these links:
You can add Out-ConsoleGridView to your system by installing the ConsoleGuiTools. You can do that by running the following:
When installed, you can use Out-ConsoleGridView to display your output inside your Terminal and use it to select or filter items. For example:
Get-Service | Out-ConsoleGridView
will show you this:
You can select one item by using Space and use CTRL-A to select them all, for example:
This is useful if you start Out-ConsoleGridview and want to use that to select several items which should be stored in a variable. For example:
$services=Get-Service | Out-ConsoleGridView
This is display all services (Just like the list in the previous screenshots), and I selected the first four items. After pressing Enter to Accept, the Out-ConsoleGridView closes, and my $services variable contains the four selected items:
C:\Users\HarmVeenstra> $services Status Name DisplayName ------ ---- ----------- Stopped AarSvc_6667e2 Agent Activation Runtime_6667e2 Running AdobeARMservice Adobe Acrobat Update Service Running agent_ovpnconnect OpenVPN Agent agent_ovpnconnect Stopped AJRouter AllJoyn Router Service
You can also filter text in the Filter line by typing one or more characters. For example:
Typing “hy” started filtering the services overview into all lines matching that.
If you want to read more about Out-ConsoleGridView, follow these links: