#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:


Filed in: Columns, Tips and Tricks Tags: ,
© 5554 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: