O'Reilly logo

Windows PowerShell™ 2 For Dummies® by Steve Seguis

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

Chapter 27. Ten Common PowerShell Mistakes

In This Chapter

  • Not allowing scripts to execute

  • Improperly using commas to separate parameters when calling a function

  • Not defining functions before using them

  • Forgetting that pipelines pass objects and not just strings

  • Not casting variables as a string

  • Making incorrect comparisons

  • Expending the pipeline to far

  • Not taking variable scope in account

  • Debugging without the debugger

  • Forgetting to use available .NET classes

Everyone makes mistakes! There's no shame in that fact, especially when you're trying to get your arms around a new scripting language. In this chapter, I talk about some typical mistakes that new Windows PowerShell users make and how you can avoid them.

Forgetting to Change the Execution Policy

The default installation security of Windows PowerShell is one of the first things that newcomers to the language run into when they try to play around with Windows PowerShell on their own. You go online, find a few commands that you like, and try them; they work great. Then you find someone who wrote a script that does exactly what you want. You've read enough to know that the script should be saved with a .ps1 file extension, and when you try to run it, you inevitably run into the exception that prevents anyone from running scripts due to the execution policy.

If you intend to run Windows PowerShell scripts, you must either digitally sign your scripts (as I discuss in Chapter 21) or not require local scripts to be signed by setting the execution ...

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