Skip to main content
Back to Study
A+ Core 2 · CompTIA 220-1202 V15 · Objective C2-4.8

Explain the basics of scripting

Objective 4.8: Explain the basics of scripting

Cert: CompTIA A+ Core 2 (220-1202) V15 Domain: 4.0 Operational Procedures Weight: Part of the 21% Operational Procedures domain Depth: Explain. The candidate must recognize script file types, common use cases, and risks of running scripts.

What this objective tests

You should recognize each scripting file type, name common scripting use cases in IT operations, and identify the risks of running scripts.

This is not a "write a script" objective. It's "recognize what scripts can do and where they live."

Key facts

.bat (Batch file):

  • Windows batch script. Runs in cmd.exe. Legacy but still widespread.
  • Simple sequential commands; limited control flow.
  • Example use: chained robocopy commands, scheduled file cleanup.

.ps1 (PowerShell script):

  • Modern Windows scripting language. Object-oriented, .NET-integrated, cross-platform (PowerShell 7+ on macOS/Linux).
  • Powerful: full Windows admin API, Active Directory module, Microsoft 365 module.
  • Default execution policy on most installs restricts running scripts; admins set policy via Set-ExecutionPolicy.

.vbs (VBScript):

  • Visual Basic Script. Older Windows scripting language, runs in cscript.exe / wscript.exe.
  • Deprecated for new development (Microsoft has signaled future removal) but still found in legacy environments.

.sh (Shell script):

  • Linux/macOS shell script. Bash is the default interpreter on most Linux distros; zsh on modern macOS.
  • Standard for *nix admin tasks: cron jobs, systemd unit scripts, deployment automation.

.js (JavaScript):

  • Browser-side scripting (web pages) and server-side (Node.js).
  • Less common as an OS admin script type but used in some automation contexts (cross-platform tooling, CI/CD pipelines).

.py (Python script):

  • Cross-platform interpreted language. Hugely popular for IT automation, data processing, scripting.
  • Standard tooling in modern admin workflows: AWS/Azure SDK, network automation (Netmiko), file processing.

Basic automation:

  • The umbrella use case. Anything repetitive that benefits from "do it the same way every time."

Restarting machines:

  • Scheduled or on-demand reboot of PCs/servers.
  • PowerShell: Restart-Computer. Bash: shutdown -r now. RMM tools do this at scale.

Remapping network drives:

  • Login script that maps Z: to the file server share for every user.
  • Batch: net use Z: \\server\share. PowerShell: New-PSDrive -Name Z -PSProvider FileSystem -Root \\server\share -Persist.

Installation of applications:

  • Silent install of software with vendor-provided silent flags.
  • Example: msiexec /i package.msi /qn. Or PowerShell wrapper invoking the installer.

Automated backups:

  • Scheduled task that runs robocopy or backup software with specific parameters.
  • Often paired with cleanup of old backup files.

Gathering of information / data:

  • Inventory script that collects hardware/software info across the fleet.
  • PowerShell: Get-CimInstance Win32_ComputerSystem. Bash: lsb_release -a; lscpu; free -h.
  • RMM agents do this continuously.

Initiating updates:

  • Trigger Windows Update, package manager updates, or vendor-specific update tools on schedule.
  • PowerShell: Install-Module PSWindowsUpdate; Install-WindowsUpdate. Bash: sudo apt update && sudo apt upgrade -y.

Unintentionally introducing malware:

  • Running an untrusted script can install malware, exfiltrate data, encrypt files, persist.
  • Verify the source of any script before running. Code-review unfamiliar scripts.

Inadvertently changing system settings:

  • A misconfigured or buggy script can change registry, disable services, edit firewall rules, with no easy rollback.
  • Test in sandbox; use change management.

Browser or system crashes due to mishandling of resources:

  • Memory leaks, infinite loops, excessive forking. A bad script can DoS the system it runs on.
  • Resource limits (ulimit on Linux, scheduled task time limits on Windows) help contain damage.

Common gotchas

  • Running a script downloaded from a random source. Especially privileged scripts. Verify source; review before running.
  • PowerShell execution policy treated as security. It's NOT a security boundary; it's a defaults-protection mechanism. Real malicious scripts bypass it. Treat as guardrail, not gate.
  • VBScript still in use. Legacy environments. Microsoft has signaled future deprecation. Migrate to PowerShell.
  • Batch file with hardcoded passwords. Plain text passwords in scripts are bad practice. Use credential vault or prompt for entry.
  • Script that worked in test crashes prod. Different data shape, scale, or permissions. Always test against representative data.
  • Login script timeout slowing user logins. Slow login script = slow user login experience. Optimize or move to async.

Real-world context

Where IT pros write scripts in 2025:

  • PowerShell: Windows admin scripting (Active Directory, Microsoft 365, Exchange, Intune, Azure).
  • Bash: Linux server admin, Docker/Kubernetes, cron jobs, CI/CD pipelines.
  • Python: Cross-platform automation, network device automation, data processing, API integrations.
  • Batch: Legacy Windows scripts; new scripts should use PowerShell instead.
  • Shell scripts on macOS: macOS admin scripts, dev environment setup.

Standard practices:

  • Source control: Scripts in Git (GitHub, Azure DevOps, GitLab). History, review, rollback.
  • Code review: Another pair of eyes before scripts touch production.
  • Idempotency: Scripts that can run multiple times without breaking. Check state before changing.
  • Logging: Every script should log what it did.
  • Error handling: Catch errors, exit cleanly, alert when something unexpected happens.
  • Comments / documentation: Future you will thank present you.

Script security:

  • Don't store credentials in scripts. Use secure vaults (Windows Credential Manager, HashiCorp Vault, cloud secret managers).
  • Sign scripts (PowerShell code signing) for production deployment.
  • Run with least privilege; only elevate when necessary.

Sources

  • [CompTIA A+ 220-1202 Exam Objectives Version 4.0, Section 4.8](../../../../../../30-RevyTechJourney/CompTIA%20A%2B%20220-1202%20Exam%20Objectives%20%284.0%29.pdf)
  • [Microsoft Learn: PowerShell documentation](https://learn.microsoft.com/en-us/powershell/)
  • [Python.org: Documentation](https://docs.python.org/3/)
  • [Linux Foundation: Bash scripting](https://training.linuxfoundation.org/)
  • [Microsoft Learn: PowerShell execution policy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies)