I found this code on the internet and it purports to remove all [,],{,} characters from the IPaddress field. However, it does not work (on PowerShell 5.1). I very much like the concept of this and would like to use a working version of this:
get-wmiobject win32_networkadapterconfiguration | where {$_.IPAddress -ne $Null} | select @{label="IP address";Expression={$_.IPAddress -replace '[{}]',''}}, MACAddress
- How can I get this to work, i.e., to remove
[,],{,}from the IPAddress field? - Additionally, how could I split the addresses such that IPv4 are in one column and IPv6 addresses are in another?
Your list of IP Addresses are actually arrays, this (
{<item1>, <item2>, <itemX>}) is just how an array is displayed in PowerShell. in other words you can just do:To separate the IP4 addresses from the IP6 addresses you can do something like: