I have created a Bot Application using Microsoft Bot Framework and want to achieve the following:
- To execute a Powershell script on remote computers without any authentication
- The powershell scripts will be hosted on Azure or on a Database (may be any)
I have done following till now:
- Was able to execute Powershell scripts on remote computers manually
- Was able to execute Powershell scripts locally using C# code
Below is my current code:
WSManConnectionInfo connectioninfo = new WSManConnectionInfo(); connectioninfo.ComputerName = "<remote computer hostname>"; Runspace runspace = RunspaceFactory.CreateRunspace(connectioninfo); //runspace.Open(); using (PowerShell ps = PowerShell.Create()) { var re = ps.AddScript("Get-Service"); var results = re.Invoke(); }