PowerShell: Fixing terminal input issues

When you start PowerShell and you are not able to enter any commands (copy/paste might still work), chances are your PSReadLine module is outdated. Fix: Update PSReadLine module Get-Module PSReadLine Version 2.0.0 # Open cmd.exe as admin and run: powershell -noprofile -command "Install-Module PSReadLine -Force" Get-Module PSReadLine Version 2.2.6

July 31, 2023

Windows: Testing network connections

Verifying that one system can connect to another system via network is a common task for managing applications. A business application that is not interconnected to some other entity is hard to find. This is a quick way to test some basic network connections on Windows without much dependencies. All you need is PowerShell and .NET which should already be included on most Windows hosts. You create a custom TcpListener (which is an instance of a ....

July 25, 2023

Unix-like `watch` and `tail` commands for PowerShell

There is no equivalent to the Unix watch command on Windows, but you can get close enough behavior. Watching commands with PowerShell # Similar to `watch <command>` PS> while ($true) {<your command>; sleep -Seconds 2} PS> while ($true) {(Get-Service -Name 'Remote Desktop Services').Status; sleep -Seconds 2} Running Running You can also follow log file output similar to the Unix tail command. Tailing logs with PowerShell: # Similar to `tail --follow <filename>` PS> Get-Content -Path <logfile> -Tail 10 –Wait PS> Get-Content -Path 'C:\app....

April 13, 2022

Getting the uptime from Windows

I was looking for a uptime like command for Windows. The uptime command on Linux: $ uptime 12:53:36 up 5:03, 1 user, load average: 0.83, 0.61, 0.36 $ uptime --pretty up 5 hours, 3 minutes $ uptime --since 2021-02-17 07:50:35 On Windows, there is the cmdlet Get-Uptime which is available for PowerShell version 6+. $ Get-Uptime -Since Monday, January 18, 2021 7:56:57 AM If Get-Uptime is not available, you can query the WMI with a CIM cmdlet....

February 17, 2021