End Google Ads 201810 - BS.net 01 --> Hi,
The c# code below shows how I am executing a powershell script on the local machine.
Do you know how it can be altered so that I can do the same thing but on a remote server?

Thanks

/// <summary>
/// Runs the given powershell script and returns the script output.
/// </summary>
/// <param name="scriptText">the powershell script text to run</param>
/// <returns>output of the script</returns>
private void PowerShellExecuteAndRun(string strServer, string strScript,
out string strResult, out string strResultFull)
{

//// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();

//// open it
runspace.Open();

//// create a pipeline and feed it the script text
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(strScript);

//// add an extra command to transform the script output objects into nicely formatted strings
//// remove this line to get the actual objects that the script returns. For example, the script
//// "Get-Process" returns a collection of System.Diagnostics.Process instances.
pipeline.Commands.Add("Out-String");

//// execute the script
Collection<PSObject> 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());
}

strResult = stringBuilder.ToString();
strResultFull = stringBuilder.ToString();

}