Alias to open latest log file in Windows Power Shell

Few days ago I’ve posted an alias to open latest log file of your application in bash shell. Same is possible on Windows environment if you use Windows Power Shell command interpreter. What you have to do is edit your profile.ps1 script and add a new function:

set-alias ed "C:/Program Files (x86)/Notepad++/notepad++.exe"
$global:app = "D:/MyApp"
function log {
   $myfile = ls $app/logs/*.log | sort -property lastwritetime | select -last 1
   ed $myfile

Of course change value for ed to your favorite editor/log viewer.
Here’s where you can read more about PowerShell profiles:

Now just restart shell and execute log command.

%d bloggers like this: