Calling Powershell scripts from C# to monitor IIS Application pool
Hi All, I recently had a requirement to monitor an application pool in one of our server and if it is gets stopped for some odd reason it must be restarted automatically. I created a windows application to achieve this task. The following are two methods which I used to check the status and if it is stopped to start the application pool. private string GetpoolStatus(string computerName,string appPoolName) { Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(); PowerShell powershell = PowerShell.Create(); PSCommand command = new PSCommand(); string result = ""; ScriptBlock scriptBlock = ScriptBlock.Cre...