I’m looking to isolate the first three octets of an IPv4 address
$IPAddress = Get-WmiObject Win32_NetworkAdapterConfiguration |
Where { $_.IPAddress } |
Select -Expand IPAddress |
where { $_ -like '*.*' } | % {
$_.SubString($_.IndexOf(""))
}
Write-host IP Address is $IPAddress
My output is currently
IP Address is 192.168.10.78
Could someone put me out of my misery and tell me what I need to do with the SubString / IndexOf in order to knock off everything after and including the final . so it reads
IP Address is 192.168.10
I’m sorry, but I’m a complete newbie, and it’s taken me 2 hours to write/steal these 6 lines
This is without using substring
this using substring: