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

Windows: Publishing a remote terminal app

When working with centrally hosted applications on Windows, I often provide such programs as RemoteApp for a good user experience. A remote app runs remotely on a terminal server, but the look and feel for a user is more like a locally installed app on a client computer - e.g. the app has its own resizable window and its own taskbar entry. Publishing a remote app For publishing remote apps, I use a variation of the following command....

July 19, 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

MSSQL: Configure an alias for SQL connections

You can use the SQL Server Configuration Manager to configure an alias for connections to a MSSQL instance. But on some versions of Windows, the configuration manager is not available as a regular application. You might find it as a snap-in for the Microsoft Management Console (MMC). If the configuration manager is generally not available on your system, you can instead use this tools to set an alias: # 64 bit version C:\Windows\System32\cliconfg....

April 12, 2022

Cygwin: A `sudo` like command

You can run commands from Cygwin with elevated permissions. On Windows, you have something like Run as different user or Run as administrator. And on Linux, you probably use the sudo command for this. To get similar functionality on Cygwin, you can add a new alias to your shell’s config file. The following is for Zsh, but it should also work for other bash-like shells. ~/.zshrc alias sudo='cygstart --action=runas' Now you can run something like this to test the alias....

February 24, 2021

Cygwin: Change the default home directory

You can define the default home directory for all Cygwin users in the nsswitch.conf file. For example, the following sets your default home directory to /cygdrive/c/Users/{user_name}/home, or in Windows notation to C:\Users\{user_name}\home. /etc/nsswitch.conf db_home: /%H/home You can change it to whatever you like. See the Cygwin documentation for more information. Look here below the /path section for more on supported wildcard characters.

February 24, 2021

Cygwin: Using the clipboard with Vim

To use the Windows clipboard in Vim on Cygwin, add the following to your Vim config file. .vimrc set clipboard=unnamed Vim will now use the clipboard register * for yank, delete, change and put operations. The * register gets synced with the Windows clipboard automatically.

February 24, 2021

Active Directory: Managed service accounts

Traditionally, system administrators use Active Directory (AD) basic user accounts with limited permissions to run a service (Service Account). Managed Service Accounts (MSA) are special accounts to eliminate the need for administrators to manually manage the credentials, passwords, and SPNs of traditional service accounts. Also, with MSAs these tasks no longer disrupt a service (no downtime). Pro Administration Automatic password changes. No manual password management. Availability No service downtime for password changes....

February 22, 2021

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