设置传输规则在 powershell 上有效,但在使用 Web 界面时失败
我有一个修改传输规则的 powershell 脚本。 它在 powershell 中完美运行,我想创建一个 Web 界面,以便非技术人员可以编辑传输规则(特别是重定向),但当我尝试从 .net 网站运行它时,set-transportrule 命令似乎被忽略。 该脚本是:
$rule = "Redirect -> " + $args[0]
$ca = (get-transportrule $rule).Actions
$ca[0].addresses = get-mailbox $args[1]
set-transportrule $box -Action $ca
$ca = (get-transportrule $rule).Actions[0]
$ca.addresses
网站将两个参数传递给脚本。
我什至尝试使用 pipeline.commands 传递各个命令,然后调用管道,但结果是相同的。
我尝试为网站提供自己的具有 NetworkService 标识的应用程序池,但它仍然不起作用。
我没有想法了,有人可以帮忙吗?
非常感谢,
安德鲁
I have a powershell script that modifies transport rules. It works perfectly from powershell and I want to create a web interface so non-tech bods can edit transport rules (specifically, redirections) but when I try and run it from a .net website, the set-transportrule command seems to be ignored. The script is:
$rule = "Redirect -> " + $args[0]
$ca = (get-transportrule $rule).Actions
$ca[0].addresses = get-mailbox $args[1]
set-transportrule $box -Action $ca
$ca = (get-transportrule $rule).Actions[0]
$ca.addresses
The website passes the two arguments to the script.
I've even tried passing the individual commands using pipeline.commands and then invoking the pipeline but the outcome is the same.
I've tried giving the website it's own application pool with the NetworkService identity and it still doesn't work.
I'm running out of ideas, can anyone help?
Many thanks,
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜这是权限不足的情况。 网络服务在设计上几乎没有权限。 尝试将应用程序池更改为您自己的凭据,并查看脚本是否有效,然后(如果有效)找出更永久的解决方案(例如专用服务帐户。)
I'm guessing it's a case of insufficient permissions. Network Service has by design almost no permissions. Try changing the app pool to your own credentials and see if the script works, then (if that works) figure out a more permanent solution (e.g. dedicated service account.)