6WRITING FUNCTIONS

Images

So far, the code you’ve written has been fairly one-dimensional: your scripts had a single task. And while there’s nothing wrong with a script that can only access files in a folder, you’ll want code that can do more than one thing as you write more-robust PowerShell tools. There’s nothing stopping you from packing more and more into a script. You could write a thousand lines of code that do hundreds of tasks, all in a single, uninterrupted block of code. But that script would be a mess to read and a mess to work with. You could break each task into its own script, but that would be a mess to use. You want one tool that can ...

Get PowerShell for Sysadmins 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.