title: Changing an IP Address in Powershell
body: <p>I am trying to get an IP address from the computer and then check the address to see if it is in a certain range. However I'm really unsure of how exactly to do this. I have figured out how to get the IP address form the computer but then checking it against the range is another story...</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>Get-WMIObject win32_NetworkAdapterConfiguration |   Where-Object { $_.IPEnabled -eq $true } |   Foreach-Object { $_.IPAddress } |   Foreach-Object { [IPAddress]$_ } |   Where-Object { $_.AddressFamily -eq 'Internetwork'  } |   Foreach-Object { $_.IPAddressToString }
  
  If ($_.IPAddressToString -eq 192.168.0.10 - 192.168.0.50)
  {Write-host $_.IPAddressToString}
  else ($_.IPAddressToString -ne 192.168.0.10 - 192.168.0.50)
  {$_.IPAddressToString = 192.168.0.15}
  </code></pre>
  
  <p>The first line is what I am using to get the IP address. I was looping up if statements so that if the address was in the range then it won't do anything but output the address. I made an else statement for the IP address to be changed if the IP is not in the right range.</p>
  
  <p>There isn't anything that I found that is in between. I don't know how to script out 192.168.0.10 - 192.168.0.50. I also couldn't really find anything that allows me to check that the IP address is in that range, so I just used equal to and not equal. Needless to say it obviously didn't work.</p>