O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.5. Testing the function

So how do we test this function? We could just run the script, as shown in figure 4.6.

Figure 4.6. Running C:\Tools.ps1

But, er, nothing happened. As you’ll learn in the next chapter, each script file acts as a kind of container. When we ran the script, it defined the Get-OSInfo function, but it didn’t run that function. Further, once the script finished, PowerShell removed everything defined by the script as part of a sort of automatic cleanup process. So now our function is gone, and we didn’t even get to see it run!

You see, once you put your commands into a function, they do become a tad bit more difficult to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required