Fatskills
Practice. Master. Repeat.
Study Guide: CompTIA A+ Core Certification: Operational Procedures - Scripting Basics
Source: https://www.fatskills.com/comptia-a-exam/chapter/comptia-a-core-certification-operational-procedures-scripting-basics

CompTIA A+ Core Certification: Operational Procedures - Scripting Basics

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~5 min read

220-1102: Objective 4.8: Identify the basics of scripting.
PC technicians are often called upon to work on, configure, and update many computers or other devices at one time, and that can mean repeating the same tasks on each machine. Waiting for long processes to run or updates to install on each machine can take a lot of time. Writing a script with all the commands and inputs enables you to run the updates automatically, saving valuable time and money.
Programming is an important technical skill, but it is beyond the scope of the CompTIA A+ exam. However, being able to identify the basics of scripting is important because the capability to run scripts as a PC technician or an administrator is an invaluable asset.

Script File Types
Script files are text files that contain instructions or commands that a computer follows to perform a task.
They can be straight text commands for an OS, or they can be written in a scripting language (a limited kind of programming language) that can be run on the computer and interpreted by the operating system. The operating system then performs the commands in the script to complete the tasks. Table 9-5 identifies and briefly describes the six common scripting languages required for the A+ exam. You should be able to recognize them by their file extensions.

Table: Basic Scripting Languages

Extension Language Basic Information
.bat Windows batch file Batch files are script files that are strictly Windows based. They are text files that contain commands or instructions for the command-line interpreter to execute. The instructions in a batch file can be interpreted only by the Windows operating system.
.ps1 PowerShell Windows PowerShell is a tool to help technicians and network administrators automate support functions through the use of scripts and snippets. Windows 10 and 11 ship with PowerShell.
.vbs VBScript VBScript, a scripting language developed by Microsoft, is considered a subset of the Visual Basic programming language. It was designed specifically for use with Microsoft Internet Explorer. It gives web pages a level of interactivity.
.sh Linux shell script A shell script is a text file that contains a sequence of commands for a Linux- or UNIX-based system. Shell scripts might not run correctly on a Windows system. Linux has had several shells; BASH (Bourne-Again Shell) is the most common of them.
.py Python Python is often a good choice for those beginning to learn programming. It is relatively easy to learn, and Python scripts can run on most operating systems. For example, Windows Shell is known as Python Interactive Shell.
.js JavaScript JavaScript is a programming language that has many uses today. It is valuable for creating scripts because it can be run on any operating system. It is usually written into web pages to create client interactions; JavaScript is read by the browser. Creating and running command-line JavaScript requires installing Node.js.

 


Scripts can be opened and read or edited in basic text editors such as Notepad, or in special programming environments that assist with commands and testing of scripts. These are often referred to as shells, and they are designed to assist in script writing.

The figure belowshows a basic “Hello World” script in Windows PowerShell. Note that the file was written in Notepad and saved as scriptdemo.ps1, using the filename extension for PowerShell.

The entire text of the script is:
“Hello World”

Images
Basic Script in Windows PowerShell

Use Cases for Scripting
The purpose of scripts is to automate tasks commonly performed by a technician. Using tasks saves time, not only in typing out the script, but also in ensuring the reliability of the input and avoiding unintended consequences from bad code.


Table: Use Cases for Scripting

 

Case Description Examples
Performing basic automation Saves time inputting commands on individual machines Using installation scripts when setting up new workstations
Restarting machines Reboots without human input Installing updates or patches
Remapping network drives Redirects resources on workstations Easing the process of system upgrades
Installing applications Runs a script with license keys and permissions Allowing simultaneous installations on workstations
Automating backups Implements scheduled backups Backing up several machines with one script
Gathering information/data Logs resource use or user logins Monitoring resources for network planning
Initiating updates Ensures security with scheduled updates and patches Scheduling checks for security patches



Other Scripting Considerations
A common frustration for people new to scripting is “fat fingering” a script with a wrong character or number and having even this type of small error cause the script to fail
. All computer languages follow strict command structures and syntax; although shells take away some of the burden, syntax still needs to be correct. When entering a script into a production environment, be sure that it has been tested in a sandbox environment first. Not doing so could result in harmful effects on the production network:
- Unintentionally introducing malware: This can be done by not checking imported scripts with security software.
- Inadvertently changing system settings: Remember that computers do not question what they are told to do. If bad scripting instructions change security or other system settings, that could open the door to disaster.
- Browser or system crashing due to mishandling of resources: Sometimes a poorly written script can instruct the computer to run a task that is beyond the power of a machine to handle. If the CPU is busy running a loop in a bad script, it does not have resources for other important tasks. Again, sandboxing should help prevent these types of errors.


This brief introduction to scripting covers the basics mentioned in the CompTIA A+ objectives, but there is much more to learn.

The following links provide more information about scripting in PowerShell, Linux, Python, and JavaScript:
- https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/ise/how-to-write-and-run-scripts-in-the-windows-powershell-ise?view=powershell-7.2
- https://help.ubuntu.com/community/Beginners/BashScripting
- www.python.org
- www.javascript.com

 

 



ADVERTISEMENT