In my last blog entry I described how you can create a custom PowerShell script template and then make the template available from within Visual Studio as a New Item entry. This could be useful when you want to perform some lightweight PowerShell based test automation to supplement your other testing activities. By writing PowerShell scripts from within Visual Studio you get the advantages of general file management and integrated .NET help. However, when you are finished with your script, in order to run your test script you’ll still need to leave the Visual Studio environment, launch an instance of PowerShell, navigate to your script and execute it. But there’s a surprising alternative. CodePlex (the Microsoft-sponsored open source effort) has a neat Visual Studio add-on that places a PowerShell host directly inside Visual Studio. The screenshot below shows what I mean. Notice there is a VSCmdShell window at the bottom of Visual Studio, and I executed my custom PowerShell script from the host. Pretty neat. With the combination of a custom PowerShell template plus the VSCmdShell Visual Studio add-on, you can, in theory, completely write and execute PowerShell test scripts in the same environment as you develop your application under test. Currently, the VSCmdShell add-on from CodePlex is a bit on the rough side and, based on my experience at least, not quite ready for serious production use. However you can try it out and decide for yourself. Let me point out that the VSCmdShell add-on is a custom PowerShell host and is not the refined command shell host you get when you install PowerShell. For example, the VSCmdShell host supports the write-output cmdlet but does not support the more flexible write-host cmdlet. Also, the VSCmdShell does not read any of the $profile startup files. And so on. I intend to keep a close eye on the VSCmdShell project and I hope the volunteer developers take the rough edges off this interesting tool.