views:

406

answers:

1

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

+1  A: 

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

Peter Seale