configuring exchange powershell hub transport rule script

Tagged: 

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of tommls tommls 1 year, 5 months ago.

  • Author
    Posts
  • #28568
    Profile photo of tommls
    tommls
    Participant

    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

  • #28573
    Profile photo of tommls
    tommls
    Participant

    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

You must be logged in to reply to this topic.