locked
-RemoteAddress only adding 1 ip range RRS feed

  • Question

  • Good afternoon

    i am scripting to create a new firewall rule.

    i need to specify 3 ip ranges but the code is only applying the first one

    can someone tell me where i am going wrong below please?

    New-NetFirewallRule -DisplayName "Test" -Program "C:\Program Files (x86)\Microsoft Office\Office14\winword.exe" -Description "AllowWord" -action "allow" -direction "inbound" -profile "Any" -RemoteAddress "192.0.0.0-192.0.0.8,10.0.0.0-10.0.0.8,127.0.0.0-127.0.0.8" -LocalAddress "Any"

    On running this it applies 192.0.0.0 - 192.0.0.8 but not the other two?

    if anyone can advise where i am going wrong i would appreciate it.

    Regards

    Friday, November 3, 2017 1:51 PM

All replies

  • … if I'm not wrong it should be an array, not a concatenated string
    -RemoteAddress '192.0.0.0-192.0.0.8','10.0.0.0-10.0.0.8','127.0.0.0-127.0.0.8'


    Best regards (79,108,97,102|%{[char]$_})-join''

    • Proposed as answer by jrv Friday, November 3, 2017 2:45 PM
    Friday, November 3, 2017 2:34 PM
  • … if I'm not wrong it should be an array, not a concatenated string
    -RemoteAddress '192.0.0.0-192.0.0.8','10.0.0.0-10.0.0.8','127.0.0.0-127.0.0.8'


    Best regards (79,108,97,102|%{[char]$_})-join''

    Superb.

    thank you!

    Friday, November 3, 2017 2:40 PM
  • Hi,

    I'm checking how the issue is going, was your issue resolved?

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, November 6, 2017 7:01 AM