Chapter 7 Creating Simple Scripts

Welcome to Chapter 7 of Learning PowerShell! In this chapter, I am going to get loopy. But before we do that, it’s crucial for us to learn how to put together some simple scripts. Once we have the framework of creating our own scripts down, we can add in some of the more advanced logic that involves loops and conditionals.

Let’s get started!

Introducing Scripts in PowerShell

Scripts in PowerShell are basically just text files with a special filename extension, ps1. To create a script, you would enter a bunch of PowerShell commands in a sequence in a new Notepad file (or you could use any text editor you like), and then save that file as NAME.ps1, where NAME is a friendly description of your script—with no spaces, ...

Get Learning PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.