# get-ParsedIPAddress.ps1
# Demostrates parsing an IP address with PowerShell
# Thomas Lee - tfl@psp.co.uk
# Parse an IP address
$ipaddress = "131.107.2.200"
$addr = [system.net.ipaddress]::parse($ipaddress)
# Display information on the returned object
$addr | gm
# Display IP address results
$addr
""
# Display address
"IP address (as Int64) : {0}" -f $addr.address
"Ip Address (as String) : {0}" -f $addr.ipaddresstostring
This script produes the following output:
PS C:\Documents and Settings\LeeT> D:\foo\get-parsedipaddress.ps1
TypeName: System.Net.IPAddress
Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object comparand)
GetAddressBytes Method System.Byte[] GetAddressBytes()
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ToString Method System.String ToString()
Address Property System.Int64 Address {get;set;}
AddressFamily Property System.Net.Sockets.AddressFamily AddressFamily {get;}
IsIPv6LinkLocal Property System.Boolean IsIPv6LinkLocal {get;}
IsIPv6Multicast Property System.Boolean IsIPv6Multicast {get;}
IsIPv6SiteLocal Property System.Boolean IsIPv6SiteLocal {get;}
ScopeId Property System.Int64 ScopeId {get;set;}
IPAddressToString ScriptProperty System.Object IPAddressToString {get=$this.Tostring();}
IPAddressToString : 131.107.2.200
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IP address (as Int64) : 3355601795
Ip Address (as String) : 131.107.2.200