1. Home
  2. /
  3. Powershell
  4. /
  5. Counter and Theme Toggle

Counter and Theme Toggle - Powershell Typing CST Test

Loading…

Counter and Theme Toggle — Powershell Code

Demonstrates a simple counter with theme toggling using PowerShell variables and console output.

$count = 0
$isDark = $false

function Update-UI {
	Write-Host "Counter: $count"
	Write-Host "Theme: $(if ($isDark) { 'Dark' } else { 'Light' })"
}

function Increment { $global:count += 1; Update-UI }
function Decrement { $global:count -= 1; Update-UI }
function Reset { $global:count = 0; Update-UI }
function Toggle-Theme { $global:isDark = -not $global:isDark; Update-UI }

# Simulate actions
Update-UI
Increment
Increment
Toggle-Theme
Decrement
Reset

Powershell Language Guide

PowerShell is a cross-platform task automation and configuration management framework, combining a command-line shell, scripting language, and object-based pipeline built on .NET. It is widely used for DevOps, system administration, cloud automation, and enterprise workflows.

Primary Use Cases

  • ▸System administration & configuration
  • ▸Cloud automation (Azure & Microsoft 365)
  • ▸DevOps & CI/CD pipelines
  • ▸Remote management & orchestration
  • ▸File management & process automation
  • ▸Infrastructure as Code (IaC) scripting

Notable Features

  • ▸Object-based pipeline
  • ▸Rich cmdlets and modules
  • ▸Native .NET integration
  • ▸Cross-platform support
  • ▸Powerful remoting capabilities

Origin & Creator

Created by Microsoft, originally released in 2006 as 'Monad' before becoming Windows PowerShell, then PowerShell Core (open-source).

Industrial Note

PowerShell dominates enterprise automation across Windows Server, Azure, Active Directory, Intune, Office 365, and hybrid-cloud DevOps environments.

More Powershell Typing Exercises

PowerShell Simple CalculatorPowerShell FactorialPowerShell Fibonacci SequencePowerShell Array ComprehensionPowerShell Hashtable FilteringPowerShell Anonymous FunctionsPowerShell Sum of ArrayPowerShell Zip ArraysPowerShell String Manipulation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher