How are parenthesis around a powershell command different than without?

Viewed 1282

I am using Get-NetIPAddress. ALL I want is the actual address without ANY formatting or tables or anything.

If I use

(Get-NetIPAddress).IPAddres

I get a list of addresses for all ports. I want only a single port so I tried to pipe it but gave nothing in return:

(Get-NetIPAddress).IPv4Address | Where-Object InterfaceAlias -eq "MyPortName"

But if I do this:

Get-NetIPAddress.IPv4Address | Where-Object InterfaceAlias -eq "MyPortName"

It says that this is an invalid command.

If I use this:

Get-NetIPAddress | Where-Object InterfaceAlias -eq "MyPortName" | Where-Object AddressFamily -eq IPv4 | Select-Object IPAddress

I get:

IPAddress
---------
10.45.22.100

So what is going on when I put parenthesis around Get-NetIPAddress and how can I get JUST the darn address number for a particular port?

4 Answers
Related