简体   繁体   English

Windows Server 2019 从 IIS (c# mvc) 调用提升的 powershell Hyper-V 脚本

[英]Windows Server 2019 calling elevated powershell Hyper-V scripts from IIS (c# mvc)

as part of c# mvc application I'm merging hyper-v machines manager, start/stop maybe in future provisioning, however though as I am able to run powershell scripts in their simplest scope I cannot manage to get around the hyper-v cmdlets to work.作为 c# mvc 应用程序的一部分,我正在合并 hyper-v 机器管理器,可能在未来的配置中启动/停止,但是尽管我能够在最简单的 Z31A1FD140BE4BEF2D11E121EC9A18 中运行 powershell 脚本工作。

I have already tried to add my application pool to Hyper-V Administrators as this is WS2019 and administrators itself and that doesn't seem to work either.我已经尝试将我的应用程序池添加到 Hyper-V 管理员,因为这是 WS2019 和管理员本身,这似乎也不起作用。 Moreover I've tried to create self-elevating ps scripts to get me through, running batch files failed and still nothing.此外,我尝试创建自我提升的 ps 脚本来让我通过,运行批处理文件失败,仍然没有。 I am using anonymous auth and don't know this might cause some issues, as I'm not so enthusiastic about.我正在使用匿名身份验证,不知道这可能会导致一些问题,因为我对此并不感兴趣。

c# ps.AddScript(scriptPath); c# ps.AddScript(scriptPath); ps.Invoke(); ps.Invoke();

for start I need to be able to manage start/stop in some most elegant way possible.对于开始,我需要能够以某种最优雅的方式管理开始/停止。 Best practices are most welcomed.最佳实践是最受欢迎的。

I will recommend that you create a dedicated Windows service application to run the Hyper-V cmdlets.我建议您创建一个专用的 Windows 服务应用程序来运行 Hyper-V cmdlet。 This service can be configured to run with a proper user account that has sufficient privileges to run the cmdlets.可以将此服务配置为使用具有足够权限来运行 cmdlet 的适当用户帐户运行。 Your webapp should communicate with this service via WCF.你的 webapp 应该通过 WCF 与这个服务通信。 In this way, you will be able to run your webapp with the default low-privilege account and guarantee the security of your system.这样,您将能够使用默认的低权限帐户运行您的 webapp,并保证您的系统的安全性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM