Communary.ConsoleExtensions

I decided to collect some of my functions intended to be used when working in the PowerShell console into one module.

I’d like to introduce my 4th PowerShell module published to the PowerShell Gallery; Communary.ConsoleExtensions.

Note that the module ‘PowerShellHumanizer‘ (also on the Gallery) are needed for this module!

At the moment it consists of 9 functions, but will probably grow in time. I’ll go through each function and show some examples of use.

Invoke-ColorizedFileListing

This function will, as the name implies, show you a colorized list of files and folders. It’s a custom implementation of Get-ChildItem that only works in the FileSystem provider, with colorization and some other usability improvements.

2016-09-10_10h50_41

The included alias for the function is ‘c‘, and in this example we see that we are using the Highlight parameter (alias ‘h’ or ‘m’) to highlight all files with the dmp extension.

Other notable parameters are Pause, ShowOwner, ShowParentDirectory and ShowSizeOnDisk.

The function also supports receiving FileSystemInfo objects through the pipeline.

Invoke-Pause

This is a small function that will pause the console output after it reaches the console height, and continue when a key press is detected.

2016-09-10_10h57_32

The included alias for this function is ‘pause‘. Use Ctrl+C to jump back to the console.

Invoke-Highlight

This function will highlight regular expression matches in color, for any text input.

2016-09-10_11h01_01

The included alias for this function is ‘highlight‘, and it can be combined with other functions, like Invoke-Pause for instance.

2016-09-10_11h02_21

Think of it like a simplified Select-String function with colorization of the matches.

Get-SpecialFolder

This function will list all the special folders with their respective paths.

2016-09-10_11h05_28

Show-Calendar

This function will show you a calendar of the current month, with today marked.

2016-09-10_11h07_15

You can also choose what date you want the calendar to show, as well as choose cultur information, and even mark a specific date on the calendar.

Invoke-Touch

This function is a PowerShell implementation of the ‘touch’ Linux command. The included alias is of course ‘touch‘. It’s main purpose is to update the date meta data for a file, as well as to quickly create empty files.

Resize-Console

This function will let you resize the PowerShell console programmatically. You can also maximize and restore the console window.

Get-ConsoleSize

This function will just list the size of the current console window.

Get-WindowState

This function will output the state of the current console window.


The last two functions are helper functions used by Resize-Console, but I include them as separate functions as well, as they might come in handy in controlling the console size from the PowerShell profile for instance.

If you like this project and want to contribute, head on over to the repository on GitHub and help out! If you just want to use it, install it directly from the PowerShell Gallery.

Bug reports and ideas for improvements are always welcome, either here on the blog, or on GitHub.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s