title: Powershell script to add multiple remote address to firewall rules
body: <p>I am trying to write a script that will loop through local firewall rules and update the remote address table. </p>
  
  <p>Here is what I have so far, it does not work. Should be simple, so not sure whats going on. The script runs without error, but does not actually update anything. </p>
  
  <pre><code>$name = Get-NetFirewallRule -DisplayName "*Desktop*" |ft   -HideTableHeaders Displayname
  $ips = "192.168.1.150, 192.168.1.151"
  foreach ($r in $name)
  {
  Set-NetFirewallRule -DisplayName $r -RemoteAddress $ips 
  }
  </code></pre>
  
  <p>The $name variable passes in the rules I want to alter by name, the $ips variable passes in the IP addresses I want. </p>
  
  <p>Does this script look right? </p>
  
  <p><strong>Updated</strong></p>
  
  <p>With the help of @Kev, whose comments/answers dissappeared for some reason, this is the working script....</p>
  
  <pre><code>$name = Get-NetFirewallRule -DisplayName "*Backup*" 
  #$ips = @("192.168.1.150", "192.168.1.151")
  foreach ($r in $name)
  {
  Set-NetFirewallRule -DisplayName $r.DisplayName -RemoteAddress $ips 
  }
  </code></pre>
  
  <p>My only other question, is why is it $r.DisplayName?</p>