🚀 POWERSHELL CHALLENGE TASKS

Network Applications (QHO443) - Week 10

Prepared by Babashaheer

Test your PowerShell skills with these progressive challenges!

📋 Instructions

🟢 Level 1 – Warm-Up Challenges

Task 1 EASY
Service Status Reporter
Create a script that asks the user to enter a service name, then checks if that service is running or stopped.

Requirements:

  • Prompt user: "Enter service name:"
  • Store the input in a variable
  • Get the service status
  • Use if/else to display: "Service [name] is Running" or "Service [name] is Stopped"
Example Output:
Enter service name: Spooler
Service Spooler is Running
Hint 1: Use Read-Host to get user input
Hint 2: Use Get-Service -Name $variablename
Hint 3: Check the .Status property and compare with -eq "Running"
Task 2 EASY
File Counter
Create a script that counts how many .txt files are in the current directory and displays the result.

Requirements:

  • Use Get-ChildItem to find .txt files
  • Count them using .Count
  • Display: "Found [X] text files in this directory"
Example Output:
Found 5 text files in this directory
Hint 1: Use Get-ChildItem *.txt to get only text files
Hint 2: Store the result in a variable: $files = Get-ChildItem *.txt
Hint 3: Use $files.Count to get the number

🟡 Level 2 – Intermediate Challenges

Task 3 MEDIUM
CPU Monitor Alert
Create a script that finds the process using the MOST CPU and displays a warning if it's using more than 50%.

Requirements:

  • Get all processes and sort by CPU (descending)
  • Select the top 1 process
  • Store it in a variable
  • If CPU > 50, display: "⚠️ WARNING: [ProcessName] is using [X]% CPU!"
  • Otherwise: "✓ CPU usage is normal"
Example Output:
⚠️ WARNING: chrome is using 67.8% CPU!
Hint 1: Use Get-Process | Sort-Object CPU -Descending | Select-Object -First 1
Hint 2: Access the process name with $process.ProcessName
Hint 3: Access CPU with $process.CPU and use -gt 50 to compare
Task 4 MEDIUM
Password Strength Checker
Create a script that asks for a password and checks if it meets security requirements.

Requirements:

  • Ask user to enter a password
  • Check if length is at least 12 characters
  • Check if it contains a number (hint: use -match '\d')
  • Display "Strong Password ✓" only if BOTH conditions are met
  • Otherwise display what's missing
Example Output 1:
Enter password: HelloWorld
❌ Password needs a number

Example Output 2:
Enter password: HelloWorld123
✓ Strong Password!
Hint 1: Use Read-Host or Read-Host -AsSecureString for password input
Hint 2: Check length: $password.Length -ge 12
Hint 3: Check for number: $password -match '\d'
Hint 4: Use -and operator to check both conditions together
Task 5 MEDIUM
Running Services Filter
Create a script that displays only the NAMES of running services, sorted alphabetically.

Requirements:

  • Get all services
  • Filter to show only Running services
  • Select only the Name property
  • Sort alphabetically
  • Display the list
Example Output:
AudioSrv
BFE
BITS
Dhcp
Dnscache
...
Hint 1: Use the pipeline: Get-Service | Where-Object | Select-Object | Sort-Object
Hint 2: Filter: Where-Object Status -eq 'Running'
Hint 3: Select: Select-Object -ExpandProperty Name (this shows just values, not a table)
Hint 4: Sort: Sort-Object at the end

🔴 Level 3 – Advanced Challenges

Task 6 HARD
System Health Check
Create a comprehensive system health check script that examines multiple aspects of the system.

Requirements:

  • Count total services and how many are running
  • Count total processes
  • Find the process using most CPU
  • Display all this information in a neat report format
  • Add a timestamp at the top
Example Output:
=================================
SYSTEM HEALTH CHECK
Date: 12/01/2025 14:30:45
=================================
Services: 85 Running / 120 Total
Total Processes: 156
Top CPU Process: chrome (45.2%)
=================================
Hint 1: Use Get-Date for timestamp
Hint 2: Store services in variable: $allServices = Get-Service
Hint 3: Count running: ($allServices | Where-Object Status -eq 'Running').Count
Hint 4: Count total: $allServices.Count
Hint 5: Use Write-Output for each line to build your report
Task 7 HARD
Large File Finder
Create a script that finds all files larger than a user-specified size and lists them with their sizes.

Requirements:

  • Ask user: "Enter minimum file size in MB:"
  • Convert MB to bytes (1MB = 1048576 bytes)
  • Find all files larger than that size in current directory
  • Display filename and size in MB for each file
  • If no files found, say "No files found larger than X MB"
Example Output:
Enter minimum file size in MB: 5

Files larger than 5 MB:
video.mp4 - 125.5 MB
backup.zip - 89.2 MB
database.db - 12.8 MB
Hint 1: Get user input: $sizeMB = Read-Host "Enter minimum file size in MB:"
Hint 2: Convert to bytes: $sizeBytes = $sizeMB * 1MB (PowerShell understands 1MB!)
Hint 3: Filter files: Get-ChildItem | Where-Object Length -gt $sizeBytes
Hint 4: Convert back to MB for display: $file.Length / 1MB
Hint 5: Use a foreach loop or pipeline to display each file
Task 8 HARD
Service Dependency Checker
Create a script that checks if critical services are running and displays a warning for any that are stopped.

Requirements:

  • Check these services: Spooler, Winmgmt, Dhcp, EventLog
  • For each service, check if it's running
  • Display "✓ [ServiceName] is OK" if running
  • Display "❌ WARNING: [ServiceName] is STOPPED!" if not running
  • At the end, show a summary: "X/4 services are running"
Example Output:
✓ Spooler is OK
✓ Winmgmt is OK
❌ WARNING: Dhcp is STOPPED!
✓ EventLog is OK
-----------------------
Summary: 3/4 services are running
Hint 1: Create an array: $services = @('Spooler', 'Winmgmt', 'Dhcp', 'EventLog')
Hint 2: Use foreach loop: foreach ($svc in $services) { ... }
Hint 3: Inside loop: $status = Get-Service -Name $svc
Hint 4: Keep a counter for running services: $runningCount = 0
Hint 5: Increment counter when service is running
🎯 Testing Tips: