java 启动 powershell 脚本的 HTML 网页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36658790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:43:41  来源:igfitidea点击:

HTML Web page that Launches a powershell script

javahtmlpowershell

提问by doobis

I am trying to find a way to host a website on a windows server in my environment. I would like to have a basic web page that can accept an entry value from the web page and then I would take that value and input it into my powershell script. My powershell script would do most the work but I have no idea how to collect data from the user and then make that data appear in my powershell script. The powershell script would run on the server side (not in front of the user) and then email them data that it collects. I would like to have a single webpage if possible. I tried to do that but also couldnt really figure that out.

我正在尝试找到一种在我的环境中的 Windows 服务器上托管网站的方法。我想要一个基本的网页,它可以接受来自网页的条目值,然后我会将该值输入到我的 powershell 脚本中。我的 powershell 脚本可以完成大部分工作,但我不知道如何从用户那里收集数据,然后让这些数据出现在我的 powershell 脚本中。powershell 脚本将在服务器端(而不是在用户面前)运行,然后通过电子邮件将其收集的数据发送给他们。如果可能的话,我想要一个网页。我试图这样做,但也无法真正弄清楚。

<!DOCTYPE html>
<html>
<head>
<title> Self Service</title>
</head>
<body>

<h1>Welcome to the Self Service</h1>
<p>Below you can enter your userID .</p>

<form action="ThankYou.html" method="post">
UserID: <input type="text" name="text"><br>
<input type="submit" value="Submit">
</form>


<input type="button" value="Launch Installer" onclick=

</body>
</html>

采纳答案by majkinetor

You have several frameworks/modules for this:

为此,您有几个框架/模块:

I used them all and the last one is probably the best for getting started and do what you want. Pipeworks is too complicated and ugly for me.

我全部使用了它们,最后一个可能是入门和做你想做的最好的。Pipeworks 对我来说太复杂和丑陋了。

You should also consider Powershell Web Accessinstead of Web application .

您还应该考虑Powershell Web Access而不是 Web 应用程序。

Perhaps the best option would be to use scriptcs and execute posh scripts from within its script. See herefor more details.

也许最好的选择是使用 scriptcs 并从其脚本中执行 posh 脚本。请参阅此处了解更多详情。

回答by Dave Wu

Try Presley? A Sinatra-like lightweight web framework written in PowerShell and can run PowerShell on server.

试试普雷斯利?用 PowerShell 编写的类似 Sinatra 的轻量级 Web 框架,可以在服务器上运行 PowerShell。