Scripting Languages – CompTIA A+ 220-1202 – 4.8

Automation and scripting is a foundational skill in IT. In this video, you’ll learn about batch files, PowerShell, shell scripts, JavaScript, Python, and more.


One topic you’ll hear quite a lot of in Information Technology is Automation and Scripting. There are a lot of different ways to automate processes, and we have a number of different scripting technologies available to us. But you have to make sure that you’re using the right script for the right purpose. The type of scripting language that you choose may be based on the application you’re running or the task that you’re performing, or it might be specific to an operating system, and there might be a limited number of options available in that OS. This means that you’ll probably learn a number of different scripting languages, so you can automate regardless of what task you’re performing.

If you’re running an automated task in Windows, you could be running a batch file. You’ll know this because the name of the file has a .bat file extension. This is something that you’ll run at the command line inside of Windows. But the use of batch files goes back to Dos and OS/2. This means that you have decades of documentation that can help you build a batch file to automate processes inside of your Windows system.

If you’re a Windows system administrator, then you’re probably not using a batch file, but instead, you’re using PowerShell. This is a command line that’s a bit of an upgrade from the batch file days, and it provides a number of additional capabilities, especially for system administrators. PowerShell Scripts commonly have a .ps1 file extension. And if you’re running Windows 10 or Windows 11, you can simply click the button to install PowerShell if it’s not installed already. PowerShell Scripts can take advantage of built in functions referred to as command-lets.

They allow you to extend the functionality of PowerShell to be able to access an operating system directly, or be able to change things in the operating system that you normally wouldn’t have access to from a standard command line and a batch file. You can even build these PowerShell Scripts into standalone executables, and simply distribute that executable to whoever needs to run that script. So if you’re doing any type of Windows administration, or you need to administer a large Active Directory infrastructure, you’ll want to become very familiar with Windows PowerShell. Windows also includes a general purpose scripting language that you can run outside of the command line. This is the Microsoft Visual Basic Scripting Edition, so you can perform functions such as a backend web server script.

You can script on the Windows desktop itself, but you commonly see these VB scripts inside of Microsoft Office applications. These Visual Basic scripts are often identified with a file extension of .vbs. As we mentioned earlier, if you’re scripting at the Windows command prompt, you’re using a batch file. But if you’re scripting inside of Linux, you’re using a Shell Script. Shell Scripts are the process used inside of Unix and Linux to be able to automate inside of a Linux Shell.

Shell Scripts don’t require a specific extension type, but we commonly put on .sh on the end of the file so that we can easily identify them. If you look at the script itself, you’ll notice that the first two characters of the script are a hash and an exclamation mark. This is known as a shebang or a hash bang, and it designates that everything following that information is a Unix or Linux Shell Script.

Another script that often works behind the scenes in our browser is JavaScript. These usually have a .js file extension, and they’re used for interactivity in our browser screens. So you go to a website, and you click something on the screen and notice that there’s some interactivity, that’s all probably being created through the use of JavaScript. It’s also important to keep in mind that there is a difference between JavaScript and Java. JavaScript is the scripting language that we use inside of our browsers.

But Java is a programming language that you would use to create applications. These have a very different use, a different implementation, and they were created by completely different organizations. So if you’re working with JavaScript, keep in mind that this is not related at all to Java.

Clou-based services have changed the way that we think about automation. This is because cloud-based services are not about a specific operating system or a specific work environment. Instead, we’d like to have scripting and automation done in the cloud that can be applied towards any operating system. That was part of the reason behind the success of Python. Python is a general purpose scripting language that works across many different operating systems and provides flexibility whether you’re in Windows, macOS, or Linux.

You’ll often see Python Scripts labeled with .py file extension. Python has a great deal of support in the industry, and has become very popular as a way to script across many different operating systems without having to change a lot of information inside the script. Here’s a simple interactive shell script. It starts with the hashbang right at the beginning, and it runs as a shell script. You can see the /bin/sh.

It has a variable called Input String that is being set to Hello. And then there is a loop as part of the Shell Script. This has an echo which means it’s putting information on the screen that says, “Please type something in or type bye to quit.” And then it waits for you to input information into the script. When you hit Enter, it echoes information to the screen that says, “You typed,” and then there’s a variable that repeats the information that you typed into the system.

It will continue through this loop until you put in the string bye. And at that point, it will say that you typed bye, and it will then quit the loop. This is a very simple example of being able to automate a process within a script. And as you become more comfortable with the scripting languages, you’ll start creating longer and more complex scripts, so that you can automate the things that normally you would have done manually.