设置传输规则在 powershell 上有效,但在使用 Web 界面时失败

发布于 2024-07-17 16:50:26 字数 595 浏览 5 评论 0原文

我有一个修改传输规则的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你爱我像她 2024-07-24 16:50:26

我猜这是权限不足的情况。 网络服务在设计上几乎没有权限。 尝试将应用程序池更改为您自己的凭据,并查看脚本是否有效,然后(如果有效)找出更永久的解决方案(例如专用服务帐户。)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文