Menu
CoddyTech

Length Check

Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 22 of 28.

challenge icon

Challenge

Easy

A password needs at least 8 characters. Add the length check under the lines you already have; keep everything you wrote so far.

  1. After the Characters line, print Length: OK when the password has 8 or more characters.
  2. Otherwise print Length: too short (need 8).

With the input Cat7, your script prints:

Password Checker
================
Password: Cat7
Characters: 4
Length: too short (need 8)

Try it yourself

# Password Checker
Write-Output "Password Checker"
Write-Output "================"
$pw = Read-Host "Password"
Write-Output "Characters: $($pw.Length)"

All lessons in PowerShell Basics