A button handler is created using custom webpart & the below code is executed to fire your PowerShell script.Ref below code- //scriptText parameter is the script which requires to pass private string RunScript(string scriptText) { // create PowerShell runspace Runspace runspace = RunspaceFactory.CreateRunspace(); // open it runspace.Open(); // create a pipeline and feed the script text Pipeline pipeline = runspace.CreatePipeline(); pipeline.Commands.AddScript(scriptText); // add an extra command to transform the script // output objects into nicely formatted strings pipeline.Commands.Add("Out-String"); // execute the script Collection results = pipeline.Invoke(); // close the runspace runspace.Close(); // convert the script result into a single string StringBuilder stringBuilder = new StringBuilder(); foreach (PSObject obj in results) { stringBuilder.AppendLine(obj.ToString()); } return stringBuilder.ToString(); }