Call PowerShell Cmdlets from C#

You can call PowerShell cmdlets directly from your C# code. First, add a reference to System.Management.Automation to your project. Unfortunately, you need to do this by editing the .vcproj file manually with NotePad or another text editor. Add the following line to the References section: