Learn about Windows PowerShell
Summary: Microsoft Scripting Guy, Ed Wilson, talks about Windows PowerShell best practices for simple scripts.
Microsoft Scripting Guy, Ed Wilson, is here. "Heyyyyy! Script it, baby!" The words of Scripting Cmdlet Style continue to echo through the house. If you have not seen the latest Windows PowerShell community video by Sean Kearney, you should definitely check it out. It is really well done, and so far, it has received four thumbs up on You Tube.
When I am working with Windows PowerShell, and the command begins to wrap to the second line, I start thinking about migrating to the Windows PowerShell ISE. If the line goes beyond two lines, I definitely move to the ISE. The reason is because command-line editing is rudimentary in the Windows PowerShell console, and also because the commands begin to be difficult to read. Also, as the length of command increases, my chance of executing the command correctly the first time decreases. If I pollute my Windows PowerShell console history with a bunch of commands that do not work properly, the whole thing becomes an exercise in futility.
Therefore, I view a simple script as only a little different than the Windows PowerShell console itself. It serves the same essential purpose: to allow me to quickly and efficiently execute simple Windows PowerShell commands. Therefore, my best practices for simple scripting are much the same as they are for the Windows PowerShell console:
That is an introduction to Windows PowerShell best practices related to quick scripts. Best Practices Week will continue tomorrow when I will talk about functions.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
Regarding 22., what are other ways to clear Powershell sessions from variables, objects, ...?
Great resource. Thanks for posting.
Some great BP tips, really good thanks
Great very helpfull