It has been discovered recently that Gihub's restful webapi has been done and is self-hosted Owin. Much more robust than the last httplistener. It seems to support Job,runspace.
Https://github.com/DimensionDataCBUSydney/PowerShell.REST.API
The process is actually relatively simple, HTML does not change, JS just need to assemble Webapi URL to modify the place, the background of PowerShell Webapi the entire replacement is OK.
Download the source code, directly generated. I used the vs2017. Then you can use it directly, and the only problem is cross-domain.
Initially in the Jquery.ajax with Jsop, but the debug response can see the returned JSON object, but Ajax is not received, it can not be displayed on the page, and Console.log (returned JSON object); There is no responsetext in it.
Most of the online searches are useless.
The front end does not have to change the back end. Mainly do not want to modify their already mature code, afraid there will be problems occur, but no way.
After some research, it is determined that the cross-domain code should be added to the Owin:
1. Installing Microsoft.AspNet.WebApi.Cors
The Startup.cs of 2.dynamicpowershellapi.owin is added using System.Web.Http.Cors;
3.line116 Add a cross-domain configuration config. Enablecors (New Enablecorsattribute ("," "," * "));
And then regenerate it, then, 10 more warnings back again--~, tested, cross-domain problem solved. The page can be displayed normally.
Html+js+powershell build AD Management System for Web Edition (ii)