Microsoft Scripting Guy Ed Wilson here. It’s a road trip. The Scripting Wife and I are heading out of town to attend a Windows PowerShell user group meeting where I will be speaking about Windows PowerShell best practices. Because I wrote a book about Windows PowerShell Best Practices, I guess people assume I know something about the subject. User groups are way cool and a great way to learn about Windows PowerShell.

We have one that meets on our Redmond, Washington, campus that is simply called the Script Club. People bring scripts they are working on that they are having problems with, or perhaps they want a second opinion about their script, and they receive lots of constructive feedback about their scripts. Receiving feedback about a script you have written is a great way to learn different approaches to scripting because you have, presumably, thought about the problem at hand and arrived at what you thought was a good solution, and now you get to see how someone else would tackle the same situation.

Hmm, that sounds an awful lot like what the 2010 Scripting Games are about: You write a solution to a problem, get to see dozens of other people’s solutions, and get to see how an internationally renowned scripter would approach the problem. In addition, during the wrap-up, you will get to see a sampling of some of the more intriguing scripts that were submitted during the games. Way cool—I can hardly wait for the events to begin.

Out of the corner of my eye, I see the Scripting Wife typing away on her laptop. She brought her power adapter and could therefore be occupied for hours.

“I get a process listing in the pain pane,” she giggled. “See.” (She showed me what is shown in the following image.)

“No I don’t see. I am trying to drive; but I think that truck driver beside us saw it and maybe that is why he is blowing his horn. Either that, or he wants his lane back,” I said. “In your command pane, type cls and pressENTER to clear the output.”

“Hey, that is pretty cool, Scripting Guy,” she enthused.

“Up in your Script pane, pipe the results of Get-Process to the Select-Object cmdlet and select the name property, please. When you are done typing, run the script by clicking the green triangle,” I instructed.

“Okay. Cool. It works just like it does on the Windows PowerShell console,” she said. (See the following image.)

“To save your script, all you need to do…”

“Is go to the File menu, and click Save while choosing a directory. No big deal,” she said.

“And what is the file extension for a Windows PowerShell script?” I asked.

“A .ps1 file. Which reminds me: When do we get to use .ps2 files?” she asked in earnest.

“You don’t. To preserve backward compatibility with Windows PowerShell 1.0 and to avoid confusion, there are no .ps2 files. But, my dear, that is a better question than you realize. Because Windows PowerShell 2.0 installs into the Windows\System32\WindowsPowerShell\v1.0 directory, I have received a number of e-mail messages in the scripter inbox with people saying the upgrade did not work because the v1.0 folder remained,” I said.

“Now don’t start getting geeky on me. I am not all that interested, just curious. I don’t want to see if you can name all of the default XML files that ship with Windows PowerShell 2.0 or anything like that. We are already married, so you can quit trying to impress me. It does not work anyway,” she laughed.

“Beautiful segue my dear. Speaking of ‘doesn’t work now,’ try to run your script,” I joked.

“You are right. It no longer works,” she said. “It gives me a bogus error.” (See the following image.)

“This is because Windows PowerShell does not allow scripts to run when it is first installed. Because you have never run a script on your computer, scripts will not run.”

“But I was running scripts earlier,” she pointed out perplexedly.

“Actually, you were running commands earlier—they just happened to be in the script pane. But you were not running a .ps1 file.”

“So how am I going to fix it?” she pleaded.

“You are not. You do not have enough rights to do that. You have to be an administrator, and I am not giving you the password. So you have two choices: You can go back to the Windows PowerShell console, open a new script, and just not save it, or play around in the command pane. We will fix it tomorrow when we get back home and I have some time to explain it to you,” I promised.

“Okay. I am wanting to learn about the registry anyway,” she said.

“Now you know why you do not have administrator rights on your laptop,” I chided.