Thursday, May 22, 2008

The 30-Day PowerShell Diet

Inspired by this example, I have resolved to go on a 30-day PowerShell diet. For 30 days I will not use the Windows command window. I will use PowerShell instead. It should hopefully take only a few days to get used to using PowerShell to do all the things I normally do in a command window, and then I can start learning all the cool extra things in PowerShell. If after 30 days I don't like it,then I will stop using PowerShell for good.

The first challenge to the beginner is getting hold of a copy. A quick search leads to the official Microsoft site, but unfortunately you can't download there without installing a Windows Genuine Advantage plug-in, which I avoid whenever possible. (Not that I'm a thief, but I consider WGA an intrusion of privacy.) Happily this site lets us take advantage of PowerShell downloading without any Genuine Advantage.

After the installation I had a shortcut to PowerShell on my Start menu, which I copied to my desktop and thence to my Quick Start tray. And then came the second challenge. I almost never run the plain vanilla command window; instead I run the Visual Studio command window, which pre-loads path and environment variables so I'll be ready to run devenv.exe, sn.exe, wsdl.exe, and the whole rest of the Visual Studio tools. The command window shortcut does this by running a batch file, which in VS2008 is called vcvarsall.bat. If you try passing the batch file as a startup parameter to PowerShell you'll get syntax errors which I'm too green to understand yet. Plus, if you make it work it won't help, because PowerShell will run the batch file in a separate process, so it won't affect PowerShell's own environment.

The solution is for the shortcut to run the batch file first, then launch PowerShell. And so I edited the shortcut's properties as follows:

* this is the default

Target: %comspec% /k ""D:\Programs\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86 && %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

And now I think I'm ready to live in PowerShell for the next 29 days.


gum said...

hi sir....

just, passing by to let you know the you refer to is wrong. and let followers know use torrents.

gum said...


My english is bad...
I'm saying that the link you refer to is wrong. and that you can get powershell 1.0 with torrents..