IT FundamentalsA+

Scripting Basics for CompTIA A+ 220-1102

Scripting automates repetitive tasks and increases technician efficiency. CompTIA A+ 220-1102 tests basic scripting concepts for PowerShell, batch files, Python, Bash, and VBScript — including use cases, syntax fundamentals, and security considerations. This guide covers every scripting concept in the A+ Core 2 objectives.

8
4 sections · 8 exam key points
1 practice questions

Scripting Languages Overview

PowerShell (.ps1): Microsoft's primary scripting language for Windows administration. Object-based output. Cmdlet-based syntax (Verb-Noun). Widely used for: Active Directory management, system configuration, automation, cloud management (Azure PowerShell). Execution policy controls whether scripts run. Batch files / CMD scripts (.bat, .cmd): legacy Windows scripting. Uses CMD commands. Simple but powerful for basic automation. Still widely used for compatibility. Python (.py): cross-platform, versatile scripting language. Used for: network automation, data processing, security scripting, web scraping, API interaction. Required by many modern tools and cloud platforms. Bash scripts (.sh): Linux/macOS shell scripting. Uses Linux commands. Essential for Linux server administration and DevOps. VBScript (.vbs): older Windows scripting language. Runs via Windows Script Host (wscript.exe or cscript.exe). Largely replaced by PowerShell. Still encountered in legacy enterprise environments. JavaScript (.js): web scripting and Node.js server-side scripting. Not typically used for Windows/Linux administration.

Script Fundamentals

Variables: store values for use throughout a script. PowerShell: $variableName = 'value'. Batch: SET variable=value, reference as %variable%. Python: variable_name = 'value' (no $ prefix). Bash: variable='value', reference as $variable. Conditional logic (if/else): execute different code based on conditions. PowerShell: if ($condition) { action } else { other }. Batch: IF condition (action). Loops: repeat code. For loop: repeat a set number of times. PowerShell: for ($i=0; $i -lt 10; $i++) { ... } or foreach ($item in $collection) { ... }. Batch: FOR %%v IN (values) DO (action). Python: for item in list: → action. Functions/subroutines: named blocks of reusable code. Error handling: try/catch blocks prevent script failure on errors. Comments: annotate code for readability. PowerShell: # comment. Batch: REM comment or :: comment. Python: # comment. Input/Output: read input from user or file; write output to screen, file, or log.

Common Scripting Use Cases

User account management: PowerShell script to create Active Directory accounts from a CSV file. Remove inactive accounts on a schedule. Password resets in bulk. System maintenance: scheduled cleanup of temporary files (PowerShell/batch). Automated disk space monitoring — alert when below threshold. Patch compliance reporting. Backup automation: PowerShell script to copy files to a network share and log success/failure. robocopy in a batch file for nightly backup runs. Network administration: PowerShell to query network adapter configuration across multiple computers. Bash script to ping a list of IPs and report unreachable hosts. Security automation: script to check for unauthorized local admin accounts. PowerShell to review audit log for failed login attempts. Reporting: generate daily system health reports as text files or HTML. Deployment: batch/PowerShell scripts for application installation during new machine setup.

Script Security

Scripts can be dangerous if misused or malicious. Malware in scripts: PowerShell is heavily abused by malware — fileless malware often uses PowerShell for command execution, download of payloads, lateral movement. PowerShell execution policy: Restricted (no scripts), AllSigned (all scripts must be signed), RemoteSigned (local scripts OK, remote must be signed), Unrestricted (all scripts). Default on Windows 10/11: Restricted. Change with: `Set-ExecutionPolicy RemoteSigned`. Script signing: PowerShell scripts can be digitally signed (code signing certificate) — prevents unauthorized modification. Script review: always review scripts from unknown sources before running. Never run scripts as administrator without understanding what they do. Obfuscated PowerShell: malware uses base64 encoding and other obfuscation to hide script content from detection. `-EncodedCommand` flag is a red flag in unexpected contexts. Secure script storage: store scripts in access-controlled locations. Don't embed credentials in scripts (use credential stores or secure vaults).

Key exam facts — A+

  • PowerShell: object-based, .ps1 files, execution policy controls script running
  • Batch files (.bat): legacy CMD scripting, commands same as CMD
  • Python: cross-platform, versatile — widely used in modern IT automation
  • Bash: Linux/macOS shell scripting (.sh files)
  • PowerShell execution policy: Restricted (default) → RemoteSigned for production use
  • Never run scripts from unknown sources without review — malware hides in scripts
  • Variables: PowerShell $var, Batch %var%, Python var (no prefix), Bash $var
  • Obfuscated PowerShell (base64 -EncodedCommand): red flag for malicious scripts

Common exam traps

Practice questions — Scripting Basics

These questions are representative of what you will see on A+ exams. The correct answer and explanation are shown immediately below each question.

Q1.

A.A. Restricted
B.B. Unrestricted
C.C. AllSigned
D.D. RemoteSigned

Explanation: RemoteSigned allows locally created scripts to run without a signature, while requiring that scripts downloaded from the internet (remote scripts) be signed by a trusted publisher. This is the recommended setting for most environments.

Frequently asked questions — Scripting Basics

Which scripting language should an A+ technician learn first?

PowerShell for Windows administration and Python for cross-platform scripting are the most valuable for A+ technicians. Start with PowerShell if you work primarily with Windows — it's built in, powerful, and directly applicable to daily tasks. Python is increasingly important for cloud, network automation, and security tasks. Batch scripting is worth understanding for legacy environments.

Practice this topic

Test yourself on Scripting Basics

JT Exams routes you to questions in your exact weak areas — automatically, after every session.

No credit card · Cancel anytime

Related certification topics