JayyCodez
JayyCodez

Reputation: 25

Get the second section of numbers from an IP address

I need to get the second section of an IP address stored in a variable for comparison reasons.

$a = "10.20.0.0"

I need to get and store the 20 as a new variable.

Upvotes: 0

Views: 33

Answers (1)

Shamus Berube
Shamus Berube

Reputation: 486

You can use Split to get what you need

$a.Split('.')[1]

This splits on the '.' and then you can access each section starting from 0.

Upvotes: 1

Related Questions