在ASP.net中的服务器端执行PowerShell命令 [英] Execute a PowerShell command on the Server-Side in ASP.net

查看:234
本文介绍了在ASP.net中的服务器端执行PowerShell命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在ASP.net中执行服务器端的PowerShell命令?

Is it possible to execute a PowerShell command on the Server-Side in ASP.net?

推荐答案

我对此表示怀疑。服务器和Web应用程序通常在<沙盒环境中执行,该环境阻止对Web操作通常所需的服务器主机系统的访问;甚至对文件系统的访问也受到为站点设置的根目录的限制。



就此而言,即使是特权的正常执行.ps1脚本文件也是如此默认情况下,user是有限的,需要加载PowerShell IDE并以交互方式发出授予此权限的命令。这与Web操作无关,但是讲述了这个故事。



毕竟,请想一想:PowerShell是......非常强大。想象一下,如果将其操作暴露给Web应用程序用户,您的安全威胁会有多大。我强烈建议你忘记这个想法。



也许你和我们分享你的想法和你的最终目标,你可以获得更积极的建议。例如,如果您只需要使用WMI,则只需使用使用System.Management.Automation; ...和...然后直接处理权限和可能的权限异常。< br $>


-SA
I doubt it. The server and Web applications are normally executed in a sandboxed environment which blocks the access to the server host's system beyond what is normally needed for Web operation; even the access to the file system is limited by the root directory set up for the site.

For that matter, even normal execution of .ps1 scrip files by a privileged user is by default limited, one would need to load the PowerShell IDE and interactively issue the command granting this permission. This is not related to Web operations but tells the tale.

After all, think at this: PowerShell is, well… powerful. Imagine how huge would be your security threat if you expose its operation to the Web application user. I would strongly advise you just to forget about the thought.

Perhaps is you share with us your ideas and your ultimate goals, you can get more positive advice. For example, if you just need to use WMI, you could simply use using System.Management.Automation;… and… then directly deal with the permissions and possible permission exceptions.

—SA


这篇关于在ASP.net中的服务器端执行PowerShell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆