8.1. Creating Scripts
The typical PowerShell script is a text file that we can create using various tools. By default, those files carry the .ps1 file extension. You can create them using Notepad, but it is best if you use a more powerful tool, one of the programmer text editors that offer features like syntax highlighting and even IntelliSense-like word completions. My favorite editor, which helped me with the examples for this book, is Notepad++, a free notepad.exe replacement that knows about many programming languages and offers syntax highlighting, word completions, and much more. You can even create scripts from the PowerShell console using here strings and the Set-Content cmdlet. Here is how to create our very first script:
PS> $code ...
Get Pro Windows 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.