Automation is a common way to manage enterprise technologies. In this video, you’ll learn about batch files, PowerShell, Visual Basic Scripting Edition, shell scripts, JavaScript, and Python.
In IT, a huge number of services are provided through automation. And to be able to provide this automation, we need to create scripts. There are a number of different options for scripting languages. And we should always find the best choice for the job.
To understand which scripting language we would use, we need to look at the task we need to perform and the operating system that we’ll use to perform it. And it’s quite likely, throughout your career, you will use one or more of these scripting languages, depending on what you need to do. The fundamental scripting language of Microsoft Windows is the batch file.
This is sometimes written with a .bat file extension. And it allows you to script information at the command line of Microsoft Windows. This is a type of scripting language that has been around since the DOS and OS/2 days.
So there’s quite a bit of capability at the command line of Windows. And we can take advantage of those capabilities by using a batch file. For example, this is a batch file that runs at a Windows command prompt that moves working documents to a production environment. It looks for anything that is a doc or txt file. It performs an XCOPY from that working environment to a production folder.
And although a batch file provides us with a lot of flexibility at the command line, there are still features within Windows that aren’t available from a batch file. To be able to access those features, we need a better version of the command line. And we get that with the Windows PowerShell.
This is a command line environment that is made for the system administrator. Almost every aspect of Windows is accessible through commands available in the Windows PowerShell. These PowerShell scripts commonly have a .ps1 file extension. And you’ll find PowerShell is already available in Windows 10, Windows 11, and a number of previous versions of Windows.
The functions within these scripts are provided through commandlets. This is a series of scripts and functions that you can run with one PowerShell script. And you also have the ability to create standalone executables from a number of these PowerShell scripts. If you need to manage services on a Windows system or configure some aspect of Active Directory, you can provide access to all of that through a PowerShell script.
Windows also includes another type of scripting called Visual Basic Scripting, or simply VBScript. You’ll see these visual basic scripts with a .vbs file extension. These are commonly used as a general purpose scripting language in Windows.
For example, you can have a backend web server scripting that is done in VBScript. You might want to script something on the Windows desktop itself. Or you may be scripting inside of a number of different Microsoft Office applications using VBScript. You can think of PowerShell as providing automation to the operating system and VBScript as providing automation to particular applications.
If you need to script at the command line within Unix or Linux, then you would run a shell script. A shell script in Linux works very similar to the way that a batch file might work in Windows. These shell scripts allow us to perform a number of automation steps at the command line in Linux. And it’s very common for a Linux system administrator to use these shell scripts to automate a number of different features inside of Linux.
One way to immediately tell that this is a shell script is to look at the first two characters of the file. You’ll notice that they start with a pound sign and an exclamation mark. In the world of Linux, we call this a shebang or a hash bang. And it’s very common to associate these with a .sh file extension.
If you’re doing some type of automation inside of a browser screen, then you’re probably using JavaScript. JavaScript files are commonly saved with a .js file extension. Almost every website you visit on the internet has some type of JavaScript that’s running in the background, even if it’s not completely obvious that script is running. This JavaScript might help fill out certain forms. Or it might change what you see on the screen, depending on what you click on.
OK. And although it’s a bit confusing, the JavaScript that runs inside of your browser is a completely different technology than the Java programming language. These are completely different languages with completely different origins. And they have a very different use and implementation in information technology.
A general purpose scripting language that runs on many different operating systems is Python. Python scripts are commonly written with a dot .py file extension. The popularity of Python has really come about due to the use of automating cloud-based services, but you can use Python for any operating system to automate almost anything at the command line. If you need to write a script that will run across many different operating systems, you might want to consider using Python.