search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Network operations with PowerShell v3 on Windows Server 8 Beta – Part 1
Posted in Windows Powershell | 1 Comment | 4,870 views | 06/03/2012 22:21

In this post, I’ll talk about network operations on Windows Server 8 Beta. I have a virtual machine on my Hyper-V server with 4 virtual network adapter. They are all binded to same network, so I can set same ip addresses on them and I’m also able to make them teamed.

1. First of all, lets get network adapters.

Get-NetAdapter

I see all network adapters with some informations like name, description, ifindex and status.

2. I’ll get one of them and see full details.

Get-NetAdapter -Name "Wired Ethernet Connection"

Btw, you can also use wildcard (*) in your commands to make them easy.

Get-NetAdapter -Name "Wired*Connection

As you see, both of them works as we expected.

3. I can see all properties of network adapter.

Get-NetAdapter -Name "Wired*Connection | fl *

But I prefer getting only useful information.

Get-NetAdapter -Name Wired*Connection | fl Name, VlanID, MtuSize, LinkSpeed, NdisVersion

4. Let’s get driver and firmware versions for a problematic scenario.

Get-NetAdapter -Name Wired*Connection | fl DriverFileName, DriverDate, DriverVersionString, NdisVersion

You can also use this for a quick driver information output:

(Get-NetAdapter -Name Wired*Connection).DriverInformation

5. Let’s get ip and dns information of this network adapter.

Get-NetAdapter -Name Wired*Connection | Get-NetIPAddress

Also thanks to Powershell v3, now we can get IP address even more easily.

(Get-NetAdapter -Name Wired*Connection | Get-NetIPAddress).IPv4Address

As you see, we don’t have any ip address on that interface. Let’s get dns information also.

Get-NetAdapter -Name Wired*Connection | Get-DnsClientServerAddress

6. Now it’s time to set ip and dns address. Let’s set ip address first.

Get-NetAdapter -Name Wired*Connection | New-NetIPAddress -IPv4Address "192.168.2.2" -PrefixLength "24" -DefaultGateway "192.168.2.1"

7. Now it’s time to add dns servers to our network adapter.

Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter -Name Wired*Connection).ifIndex -ServerAddresses "8.8.8.8","8.8.4.4"

8. Let’s add second ip address to our network adapter.

Get-NetAdapter -Name Wired*Connection | New-NetIPAddress -IPv4Address "192.168.2.50" -PrefixLength "24"

Please let me know if you require additional network operations. Teaming etc. will be on next part.

Applied to: PowerShell v3


Comments (1)

Ivo

October 25th, 2014
20:41:36

The command “Get-NetAdapter -Name Wired*Connection | fl DriverFileName, DriverDate, DriverVersionString, NdisVersion” does not list the firmware versions. It list the driver version. Do you know how to list the firmware version of the NIC?



Leave a Reply