user2844129
user2844129

Reputation: 133

Gather IP address information

I'm struggling to find info on differences between the PowerShell versions, but it's all pretty mixed up.

What commands are there available for network commands in PowerShell 3 installed on Windows 7? As far as I've read, many modules need to be imported separately, but I couldn't find any for the get-netipaddress cmdlet, or others similar, that are available in Win8 or Win Server 2012, but not on win7. Is there a module that can be imported in Win7 for it? Perhaps there is a similar command in PS v2?

Update: I'm running v3. And from what I've read, that command is available on PowerShell 3, but not installed on Win7. But why would that be the case?

enter image description here

Upvotes: 3

Views: 30431

Answers (5)

Tyler Montney
Tyler Montney

Reputation: 1502

Ran across Get-NetIPAddress first, but need it to work across Win7, too. Win32_NetworkAdapterConfiguration seems to give more than enough.

(Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object {($_.IPEnabled -eq $true) -and ($_.DHCPEnabled -eq $true)} | Select IPAddress).IPAddress

That is an example of my use case. IPEnabled seems to filter out virtual/"fake" adapters, and DHCPEnabled to find non-statically assigned addresses (because these are mostly client machines and don't care about edge cases). Basically, to get "the most real IP" possible.

Upvotes: 0

Lance U. Matthews
Lance U. Matthews

Reputation: 16596

I don't know what structure the Get-NetIPAddress cmdlet returns its data in, but if you're looking for a way to retrieve IP settings you can use WMI and the Win32_NetworkAdapterConfiguration class:

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter 'IPEnabled = True'

The System.Net.NetworkInformation namespace has a number of classes you can use to retrieve the same kind of information:

[System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() `
    | ForEach-Object { $_.GetIPProperties() } `
    | Select-Object -ExpandProperty 'UnicastAddresses';

Upvotes: 14

guest
guest

Reputation: 41

I've been very frustrated with the lack of this particular cmdlet in Pre-Win8, Server2012 PS. One way of getting your TCPIP setting into PS for manipulation is to set a variable to the output of an ipconfig command for example: $ipconf = ipconfig

This will give you most of the same information that get-netipaddress will give you.

The next command will filter out all but the IP addresses-

$ipconf = $ipconf -match "IPv"

But this will return something formatted like :

IPv4....................... : 192.168.0.1

If you want to get just the IP address:

$ipconf = $ipconf.split(":")[1]

Upvotes: 4

Scott Chamberlain
Scott Chamberlain

Reputation: 127543

Get-NetIPAddress is not part of powershell but of windows server itself. I recommend running windows server in a VM and doing your studies from there.

You can download a 180 day evaluation ISO or VHD from this link and use the trial to do your studies.

Upvotes: 1

mikekol
mikekol

Reputation: 1862

PowerShell releases only ship with a "core" set of cmdlets, and it's only that set of cmdlets that are altered when you install a new version of PowerShell.

Cmdlets like Get-NetIPAddress aren't actually part of PowerShell - they're part of the underlying OS, in this case, Windows 8.1 and Windows Server 2012 R2. They rely on functionality in specific OS versions, so they're bundled with the OS, and not the management framework.

So, unfortunately, the answer to your question is that there's nothing you can do to get Get-NetIPAddress to work on Windows 7, short of upgrading to Windows 8.1.

Upvotes: 9

Related Questions