Search⌘ K
AI Features

Creating Scripts

Explore how to create your first script in both PowerShell and Python, learning to save script files and run them using various methods like the console, command prompt, or shell. Understand practical approaches to automate tasks with scripting in both environments.

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 ...