Introduction
Project 1: Random Password Generator
function Generate-Password {
param (
[int]$length = 10
)
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*'
$password = ''
for ($i = 0; $i -lt $length; $i++) {
$password += $chars[(Get-Random -Maximum $chars.Length)]
}
return $password
}
$randomPassword = Generate-Password
Write-Host "Your random password is: $randomPassword"
Project 2: Text-Based Adventure Game
Write-Host "Welcome to the Adventure Game!"
function Get-PlayerChoice {
$choice = Read-Host "Do you want to go left or right? (L/R)"
if ($choice -eq 'L') {
Write-Host "You've found a treasure chest! 🎁"
} elseif ($choice -eq 'R') {
Write-Host "You've encountered a dragon! 🐉"
} else {
Write-Host "Invalid choice. Try again!"
Get-PlayerChoice
}
}
Get-PlayerChoice
Project 3: File Organizer
$sourceFolder = "C:\Example\UnsortedFiles"
$destinationFolder = "C:\Example\OrganizedFiles"
Get-ChildItem $sourceFolder -File | ForEach-Object {
$extension = $_.Extension.TrimStart('.')
$targetFolder = Join-Path $destinationFolder $extension
if (-not (Test-Path $targetFolder)) {
New-Item -ItemType Directory -Path $targetFolder | Out-Null
}
Move-Item $_.FullName $targetFolder
}
Write-Host "Files have been organized! 📂"
Conclusion
Now you have some fun and creative PowerShell projects to try! These beginner-friendly projects will help you learn PowerShell while having a blast. Happy coding! 😃