title: PowerShell: Convert IP Address to Subnet
body: <p>I was able to extract my computer's host IP address using the ff:</p>
  
  <pre><code>$IPAddr = Get-NetIPConfiguration -InterfaceAlias "Ethernet" | select IPv4Address 
  </code></pre>
  
  <p>How do I get it's corresponding subnet address based on its subnet mask (e.g. <code>/24</code>, <code>/20</code>, <code>/16</code>, etc.)? </p>
  
  <p>So, if the host IP address is <code>192.168.100.45</code>, and the subnet mask is <code>/24</code> or <code>255.255.255.0</code>, the code should get the subnet address value of <code>192.168.100.0</code>. </p>