Introduction
I was at WPF training last week in Phoenix, AZ that was provided by DevelopMentor. As part of the training I was working on a sample application that, of course, needed to be able to execute PowerShell scripts. Unfortunately it is not easy to add the required assembly System.Automation.Management to your project as reference. You have to open the *.cproj file with a text editor and add a Reference element for System.Automation.Management manually.You could also add the assembly System.Management.Automation.dll to your project from the Reference Assemblies folder, but that would require you to install the Windows 7 SDK.

Figure 1: WPF Essentials in Phoenix, AZ
This blog post combines all my findings and provides easy access to the reference assemblies and a project template that lets you create a Hello-World-WPF-With- PowerShell application.
Windows SDK
The System.Management.Automation.dll gets installed, besides in the GAC, in the reference assemblies folder as part of the Windows 7 SDK. In addition the SDK installs several PowerShell SDK code samples. These samples are located in:
C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\sysmgmt\windowspowershell
There are samples for creating your own scripting host, snap-in and PowerShell provider.

Figure 2: PowerShell SDK as part of the Windows SDK
The reference assemblies needed for using the PowerShell SDK are installed here:
C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0

Figure 3: 32-Bit PowerShell assemblies
and here:
C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0

Figure 4: 64-bit assemblies
The samples and reference assemblies used in the Windows 7 PowerShell SDK can be downloaded here: PowerShell 2.0 SDK.zip
PowerShell namespaces and assembly references with access to SDK
When extending PowerShell you need to add a reference to the System.Management.Automation.dll and add the following namespaces to your project.
- System.Management.Automation
- System.Management.Automation.Host
- System.Management.Automation.Runspaces

Figure 5: PowerShell SDK project configuration
PowerShell namespaces and assembly references without access to SDK
If you don’t have the SDK installed but still need to use PowerShell’s scripting engine in your project then you can either modify the *.cproj project file manually as described below or just download the sample projects or Visual Studio 2010 template that is ready to go.

Figure 6: Create new WPF Application

Figure 7: Open *.cproj with notepad

Figure 8: Add the line with System.Management.Automation to the Reference ItemGroup

Figure 9: The Hello World from WPF application
Download
The sample project and the WPFPowerShellHost Visual Studio 2010 template can be downloaded here: WPFPowerShellHostSampleAndProjectTemplate.zip