#PSTip Provide CapsLock status in Read-Host prompt

In Windows, you get a message about the CapsLock status when logging on to Windows OS and with CapsLock on. You see this kind of experience in many other applications including web applications.

A similar experience, if not the same, can be provided in a simple manner when asking for password input using Read-Host cmdlet in a script.

Read-Host -Prompt "Enter Password $(if([console]::capslock){'(CapsLock is ON)'})"

Here is how it looks:

Share on: