Click here to Skip to main content
15,885,908 members
Home / Discussions / C#
   

C#

 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
jo H20-Jul-09 5:33
jo H20-Jul-09 5:33 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
chrisx5120-Jul-09 5:38
chrisx5120-Jul-09 5:38 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
jo H20-Jul-09 6:18
jo H20-Jul-09 6:18 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
chrisx5120-Jul-09 21:39
chrisx5120-Jul-09 21:39 
AnswerRe: Framework Version - using 2.0 instead of 3.5 Pin
Wendelldh21-Jul-09 3:58
Wendelldh21-Jul-09 3:58 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
chrisx5121-Jul-09 4:47
chrisx5121-Jul-09 4:47 
GeneralRe: Framework Version - using 2.0 instead of 3.5 Pin
Wendelldh21-Jul-09 5:09
Wendelldh21-Jul-09 5:09 
Questionexecute powershell script on remote machine Pin
arkiboys20-Jul-09 3:38
arkiboys20-Jul-09 3:38 
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();

            }
QuestionWindows Form does not show if created in other thread Pin
gehbitte20-Jul-09 3:33
gehbitte20-Jul-09 3:33 
AnswerRe: Windows Form does not show if created in other thread Pin
stancrm20-Jul-09 3:39
stancrm20-Jul-09 3:39 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 4:27
gehbitte20-Jul-09 4:27 
GeneralRe: Windows Form does not show if created in other thread Pin
DaveyM6920-Jul-09 4:41
professionalDaveyM6920-Jul-09 4:41 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 4:59
gehbitte20-Jul-09 4:59 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 5:04
gehbitte20-Jul-09 5:04 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 5:40
gehbitte20-Jul-09 5:40 
GeneralRe: Windows Form does not show if created in other thread Pin
DaveyM6920-Jul-09 7:51
professionalDaveyM6920-Jul-09 7:51 
GeneralRe: Windows Form does not show if created in other thread Pin
gehbitte20-Jul-09 21:41
gehbitte20-Jul-09 21:41 
AnswerRe: Windows Form does not show if created in other thread Pin
Luc Pattyn20-Jul-09 3:51
sitebuilderLuc Pattyn20-Jul-09 3:51 
QuestionHorizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 3:21
iscript20-Jul-09 3:21 
AnswerRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
DaveyM6920-Jul-09 3:31
professionalDaveyM6920-Jul-09 3:31 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 3:39
iscript20-Jul-09 3:39 
AnswerRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
stancrm20-Jul-09 3:31
stancrm20-Jul-09 3:31 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. [modified] Pin
iscript20-Jul-09 3:43
iscript20-Jul-09 3:43 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
Luc Pattyn20-Jul-09 3:53
sitebuilderLuc Pattyn20-Jul-09 3:53 
GeneralRe: Horizontal ScrollBar does not work in the TextBox control... anymore. Pin
iscript20-Jul-09 4:28
iscript20-Jul-09 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.