By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
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
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” 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
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
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.