Creating Scripts

Learn how to create and run scripts in PowerShell and Python.

Creating our First Script

Scripts are programs written for a special runtime environment that can automate a list of tasks or operations which would have otherwise been done manually. A script can consist of nearly any number of lines of code, written to meet a certain requirement. In this chapter, we will learn to create our first script and various approaches to run them in PowerShell and Python.

Saving Commands as a Script File

PowerShell scripts are just a text file saved with a .ps1 extension. That is all we need to create a script. Simple!

On the other hand, Python scripts are saved as a .py extension.

Once the files are saved, we can see them in File Explorer with ...