Scripting Basics Explained – CompTIA A+ 220-1202 (Objective 4.8)

Every IT pro needs to know scripting—it automates boring tasks, saves time, and makes life easier. In this video, you’ll learn scripting fundamentals for the CompTIA A+ (220-1202) exam, including scripting use cases, key scripting languages (PowerShell, Batch, VBScript, Shell, JavaScript, Python), and best practices for safely running scripts.

🎓 From the course: Operational Procedures for CompTIA A+ Core 2 (220-1202)

Watch my 100+ courses on Pluralsight

Video Summary

  • Scripting is an essential skill for IT professionals. It automates tedious tasks like updating servers at odd hours, installing applications across multiple devices, and compiling reports from hundreds of folders—all things nobody wants to do manually.
  • There are six key scripting languages to know for the A+ exam: PowerShell, Batch, VBScript, Shell Script, JavaScript, and Python. While you don’t need deep expertise in each, understanding their use cases helps determine which one fits your needs.
  • The choice of scripting language depends on the task. Whether it runs on Windows, Unix, or a browser dictates which language works best. IT professionals often use multiple scripting languages throughout their careers to optimize workflows.
  • Scripting can handle various tasks. It’s used for installing applications, backing up data, gathering system information, mapping network drives, and automating updates—such as rebooting users’ machines at night when they forget.
  • Never blindly copy and paste scripts from the internet. Without understanding them, you risk altering system settings, introducing malware, or crashing your system. Always review scripts thoroughly before using them in production.

For more information, read the transcript blog below, or watch the video above!

Transcript

If there’s one skill that every IT professional uses daily, it’s scripting. Let’s dive into the fundamentals. Scripting is what allows IT professionals to automate boring tasks—and there are a lot of them. For example, do you want to wake up at 2 a.m. to start updates or backups on a server? Or manually install applications on every new company laptop? And sometimes we need to create reports. Do you want to go through 100 folders, look at the properties of each one of them, their metadata, and copy-paste that into an Excel spreadsheet? Probably not. None of those sounds like fun.

By scripting and automating certain tasks, we can focus on the more fun parts of the job, such as new projects that will make the company—and, of course, our users—more productive. We have many scripting languages available, but for the A+ exam, there are six that you need to know about, as well as their file extensions. We have PowerShell, Batch, VBScript, Shell Script, JavaScript, and Python.

Now, for the A+ exam, you just need to know about them. You don’t need to know how to use each one of them in detail. But now you might be wondering, “If I have so many options, and I want to study one of them, which one should I learn?” The truth is, it depends. The scripting language you choose will depend on your requirements at that point in time—such as the task you need to do, what operating system it will run on, or even whether it runs in the browser instead of on an operating system.

As an IT professional, you will end up using many scripting languages throughout your career, and scripting is one of the most important skills you will have. The languages you use will depend on the task, and hopefully, throughout your career, you’ll end up mastering many of them.

So, what are some use cases for scripting? You can use it to install applications. You can use it for scheduling or performing backups. One of the most common use cases is gathering information and creating reports. You can also use it to map network drives and install updates. And remember when we said that people don’t reboot their machines often enough? Well, you can do it at night with scripting.

With the basics covered, let’s take a look at some examples and best practices.

Let’s start with Batch files. Batch files are simple scripts for automating tasks in Windows using command-line instructions. They are commonly used for administrative tasks like file management, system configuration, and automation. In this example, we restart a PC. So, we first print a message for the user by using the echo command that the PC is restarting in 60 seconds. Then, the second line schedules a restart in 60 seconds.

Next up, PowerShell is a powerful scripting language designed for managing Windows environments. It integrates deeply with system settings and can execute commands beyond what Batch files can do. This example maps a network drive named Z: to a shared folder. You will see that PowerShell commandlets always have a verb—in this case, “New”—then a dash, then the prefix of the module they work with, and then a noun. So, New-PSDrive. And then finally, Write-Host it will display a message that this has successfully been done.

Next up, we have VBScript. VBScript is a lightweight scripting language that automates tasks in Windows. It’s often used for simple scripts for automation in corporate environments. In this script, we install an application silently. We first initialize a shell to execute commands, and then we use the Run command to execute the MSI installer. The 1, True at the end ensures that the script waits for the installation to complete before proceeding.

Now, let’s move away from Windows. Shell scripts are used to automate tasks in Unix-based systems, such as Linux and macOS. They execute shell commands in sequence. In this backup script, we first define the script as a bash shell script, and then use the tar command to compress, zip, and name the backup file. The echo command will simply print a confirmation message at the end.

Next up, let’s talk about JavaScript. JavaScript is typically used for web development, but it can also run on Windows via the Windows Script Host for automation. In this script, we aim to gather system information, first by using the Windows Script Host and then running the exec system info to retrieve the operating system details. Next, we simply output the information one line at a time.

Finally, Python is a versatile scripting language used for automation, data processing, and system administration. In this script, we import the operating system module to execute system commands. We show a message that we are looking for Windows updates, and then we force Windows to check for updates with the DetectNow parameter. Finally, we force the installation of available updates with the UpdateNow parameter.

Before we go into the demo, I do want to tell you something very important. You should never use scripts from the internet that you do not fully understand. These days, so many people go to Reddit or Stack Overflow—or even use GenAI to generate scripts—and then simply copy and paste them into production without understanding them. You should never do that. If you run scripts that you do not understand, you could change system settings by accident because you don’t know what parameters to change for your needs. Or even worse, you could unintentionally introduce malware. Remember, not everyone on the internet is a good person. Finally, badly designed scripts could also crash systems if they do not handle resources properly.

Back in the lab, let’s take a quick look at some examples of scripting. Let me open up the Windows Terminal over here. First of all, let’s do some PowerShell. One of the things that we can do with scripting is create reports. And for the CompTIA A+ exam, you don’t necessarily need to know how to do every single thing in PowerShell. So, I’ll just show you this example: I’m connecting to SharePoint Online and getting all the different sites that are of type personal site—so, my OneDrive for Business sites. Then, I’m displaying them as a table where I have my URL, my storage usage (current), as well as my storage quota. This again only took me a few seconds to do with PowerShell. I do not have this report anywhere in the user interface, so that is a huge timesaver—being able to use scripting to create reports.

Now, let’s switch over to Batch. If you remember a couple of modules ago, we installed a collection agent to get information about our PC in the asset management system. Well, I uninstalled it, but right now I want to reinstall it using the command line. So, what I will use is the msiexec command. You’ll see we’re passing parameters over here. As you learn, you’ll know what the /i is, which, if we look at the documentation, means a normal installation. If we search for qn here, which is another one we’ll mention, it specifies that there is no UI during the installation process. So, we often call this a “silent installation.” And I’m even passing the site key as a parameter, so it doesn’t ask the user anything. That’s it. That is all I had to do. Now, it will take anywhere from a couple of seconds to a couple of minutes—and there we go—it has already been installed.

So, those are two quick examples of using PowerShell to create reports and using Batch to install an application on a computer fully silently, with no user interaction needed.

Blogs and Videos