Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.9.1. Script Types and Basic Constructs

💡 First Principle: Different scripting languages exist because different environments have different native capabilities. PowerShell is the native Windows automation language; bash is the native Linux shell. Understanding which tool works in which environment is prerequisite to understanding when to use each.

Script Types
Script TypeEnvironmentStrengthsFile Extension
PowerShellWindows (also cross-platform)Deep Windows/AD integration, objects (not text), remoting.ps1
BatchWindows (legacy)Simple, runs on all Windows versions, no dependencies.bat, .cmd
BashLinux/Unix/macOSText processing, system integration, widespread.sh
VBScript (VBS)Windows (legacy)COM object automation; largely replaced by PowerShell.vbs
Environment Variables

Environment variables store configuration values accessible to scripts and processes without hardcoding them:

  • Windows: %SystemRoot%, %USERNAME%, %COMPUTERNAME%
  • Linux: $HOME, $PATH, $USER
Basic Script Constructs
# PowerShell example — shows all three constructs
$servers = @("server01", "server02", "server03")  # Array variable

foreach ($server in $servers) {                    # Loop
    if (Test-Connection -ComputerName $server) {   # Conditional
        Write-Host "$server is online"
    } else {
        Write-Host "$server is OFFLINE"            # Comparator result
    }
}
ConstructPurposePowerShell ExampleBash Example
VariablesStore values$name = "value"name="value"
LoopsRepeat actionsforeach ($x in $list)for x in list
ConditionalsBranch logicif ($x -eq 5)if [ $x -eq 5 ]
ComparatorsCompare values-eq, -ne, -gt, -lt=, !=, -gt, -lt
Basic Data Types
  • Integers: Whole numbers (42, 1024)
  • Strings: Text values ("server01", "C:\Logs")
  • Arrays: Collections of values (@("server01", "server02") in PowerShell; space-separated in bash)
Comment Syntax
LanguageComment CharacterExample
PowerShell## This is a comment
Bash## This is a comment
BatchREM or ::REM This is a comment
VBScript'' This is a comment

⚠️ Exam Trap: PowerShell uses -eq for equality comparison, not ==. Using == is a common mistake for developers coming from other languages. The exam tests basic construct syntax recognition.

Reflection Question: A script needs to check whether a list of servers is online and send an alert if any are offline. Which script construct is responsible for checking each server in the list, and which handles the "if offline, alert" logic?

Alvin Varughese
Written byAlvin Varughese
Founder18 professional certifications