In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Recently, it is found that someone on gihub has already done a good job of powershell's restful webapi, and it is self-host owin. Much more robust than the httplistener I used last time. It still seems to support job,runspace.
Https://github.com/DimensionDataCBUSydney/PowerShell.REST.API
In fact, the process is relatively simple, html does not need to change, js only needs to modify the place where the webapi url is assembled, and the whole powershell webapi in the background will be replaced by ok.
Download the source code and generate it directly. I use vs2017. Then it can be used directly, and the only problem is cross-domain.
At first, jsop is used in jquery.ajax, but the returned json object can be seen in the response of debug, but even if ajax cannot receive it, it cannot be displayed on the page, and console.log (returned json object); there is no responseText at all.
Most of the searches on the Internet are useless.
If the front end doesn't work, we'll have to change the back end. The main reason is that I don't want to modify other people's mature code, for fear that there will be problems, but there is no way.
After some research, it is finally decided that cross-domain code should be added to owin:
1. Install Microsoft.AspNet.WebApi.Cors
Startup.cs of 2.DynamicPowerShellApi.Owin joins using System.Web.Http.Cors
Join the cross-domain configuration config.EnableCors at 3.line116 (new EnableCorsAttribute ("," * "))
And then regenerate, it's fine, and we'll talk about it later with 10 more warnings-after testing, the cross-domain problem is solved. The page can be displayed normally.
Today, I found that it could not be displayed in Chinese, but in the original Line123 of PowerShellRunner.cs,
? Regex.Replace (psOutput.LastOrDefault (). ToString (), @ "[^\ u0000 -\ u007F]", string.Empty) regularly matches all non-Latin characters and replaces them with blanks, resulting in no output of text other than English.
Solution correction rule
Like what? Regex.Replace (psOutput.LastOrDefault () .ToString (), @ ", @") just replace nothing.
This is basically what the back end looks like, if you have a better plan to communicate.
As for the front end, it feels good to use vue. Componentization is really convenient.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.