Author Posts

August 13, 2015 at 10:31 am

I am working on a script to create multiple hub transport rules in Exchange 2010.

My code is:
`
$names=@('foo','bar')
foreach ($name in $names) {
set-transportrule -identity "export" + $name + "test redirect domain1 to domain2" -sentto=$name+@domain1.org -redirectmessageto=$name +@domain2.org -state=disabled
}
`
Is my set-transportrule line written correctly?? (in terms of syntax??)
I know the other lines are syntactically correct (array, foreach)
This is a multi-line script. Do I start it as a *.ps1 script inside the Exchange PS Shell, or what??
Thank you, Tom

August 13, 2015 at 11:34 am

I got it now...
cls
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$names=@('tlyczko')
foreach ($name in $names) {
new-transportrule "export $name test redirect mls to mso" -sentto "$name@mountainlakeservices.org" -redirectmessageto "$name@ncmso.org"
#set-transportrule -identity "$name test redirect mls to mso" -redirectmessageto "$name@ncmso.org"
disable-transportrule "export $name test redirect mls to mso" -force
}
Now to play with it more etc.
Thank you, Tom