Convert IP address to decimal value (and back)

by May 31, 2013

Sometimes you may want to convert an IP address to its decimal value, for example, because you want to use binary operators to set bits. Here are two simple filters that make this a snap:

filter Convert-IP2Decimal
{
    ([IPAddress][String]([IPAddress]$_)).Address
}


filter Convert-Decimal2IP
{
([System.Net.IPAddress]$_).IPAddressToString 
}

And this is what you can do with them:

Twitter This Tip! ReTweet this Tip!