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

5.1.8. Explain the basics of scripting. (Obj. 4.8)

šŸ’” First Principle: Scripting automates repetitive tasks, improving efficiency and reducing the potential for human error. If you do something more than twice, script it.

At its core, a script is just a simple computer program written as a plain text file. It contains a series of commands that are executed in sequence by an interpreter. The power of scripting is automation. If you find yourself performing the same set of command-line tasks over and over again, you can put those commands into a script and then run the script with a single command. This saves time, ensures the task is performed exactly the same way every time (reducing errors), and allows non-technical users to perform complex tasks.

Script Types Quick Reference:
TypeExtensionPlatformUse CaseSecurity Note
Batch.batWindowsSimple automation, drive mappingRuns immediately on double-click
PowerShell.ps1WindowsAdvanced admin, system managementExecution policy blocks by default
Shell.shLinux/macOSSystem administration, automationRequires execute permission (chmod +x)
Python.pyCross-platformData processing, complex logicRequires Python interpreter
JavaScript.jsWeb/Node.jsWeb automation, server-side tasksBrowser sandboxed; Node.js unrestricted

PowerShell 7.5 on Windows 11 Figure: PowerShell 7.5 running in Windows Terminal - the modern automation framework for Windows administration

Deep Dive: Script Language Characteristics
  • Batch files (.bat): The original scripting language for Windows. Uses DOS-style commands like copy, del, echo. Simple but limited - no objects, weak error handling. Still useful for quick tasks.

  • PowerShell (.ps1): The modern Windows automation framework. Key insight: PowerShell works with objects, not text. When you run Get-Process, you get process objects with properties like .CPU and .Memory, not just lines of text. This makes it incredibly powerful for system administration.

    Critical Security Feature: By default, PowerShell will NOT run scripts (execution policy is Restricted). You must explicitly change this using Set-ExecutionPolicy. Common policies:

    • Restricted - No scripts run (default)
    • RemoteSigned - Downloaded scripts must be signed; local scripts run freely
    • Unrestricted - All scripts run (dangerous)
  • Shell script (.sh): The standard for Linux and macOS. Runs in Bash or other shells. The first line (#!/bin/bash) tells the system which interpreter to use - this is called the shebang.

  • Python (.py): Readable, powerful, cross-platform. Excellent for complex logic, data manipulation, and when you need libraries (e.g., for working with APIs, Excel files, or databases).

  • JavaScript (.js): Primarily for web browsers, but Node.js allows server-side execution. Used for web automation and modern tooling.

Practical Examples:
Batch File - Map Network Drives:
@echo off
REM Map sales department drives
net use S: \\FILESRV01\Sales /persistent:yes
net use T: \\FILESRV01\TeamDocs /persistent:yes
net use P: \\FILESRV01\Public /persistent:yes
echo All drives mapped successfully!
pause
PowerShell - System Health Check:
# Get disk space on C: drive (objects, not text!)
$disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='C:'"
$freeGB = [math]::Round($disk.FreeSpace / 1GB, 2)
$totalGB = [math]::Round($disk.Size / 1GB, 2)
$percentFree = [math]::Round(($disk.FreeSpace / $disk.Size) * 100, 1)

Write-Host "C: Drive: $freeGB GB free of $totalGB GB ($percentFree% free)"

if ($percentFree -lt 10) {
    Write-Host "WARNING: Low disk space!" -ForegroundColor Red
}
Shell Script (Linux) - Clear Temp Files:
#!/bin/bash
# Clear temporary files older than 7 days
echo "Cleaning temp files..."
find /tmp -type f -mtime +7 -delete
echo "Done! Cleaned files older than 7 days."
Common Use Cases for Help Desk:
  • User onboarding: Map drives, install standard software, configure printers
  • Maintenance: Clear temp files, check disk space, restart services
  • Reporting: Gather system info, check for updates, audit installed software
  • Troubleshooting: Reset network settings, clear caches, repair common issues

Technician's Insight: You don't need to be a programmer, but you should be able to:

  1. Identify script types by extension
  2. Understand what a script is doing at a high level
  3. Modify existing scripts (change a path, add a command)
  4. Know the security implications (especially PowerShell execution policy)

Reflection Question: A user double-clicks a .ps1 file and nothing happens. What is the most likely cause, and how would you enable them to run it safely?

Alvin Varughese
Written byAlvin Varughese
Founder•15 professional certifications