It is so easy. First, lets put our c# code into a powershell string. Here is the example. $exampleCode=@’using System; using System; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Windows.Media.Imaging; using System.Xml; public partial class Form1 : Form {